• alfredobenni

    (@alfredobenni)


    Very nice plugin
    Hi, every 15 seconds I have to run a php script. I think I use a script that runs JavaScript -> Ajax -> PHP. Where an example using your plugin?
    Where can I find documentation on how to run Ajax applications with this plugin? If it is possible.
    Alternatively, is it possible to run the single PHP script by timing?
    Best regards
    Alfredo

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author webcraftic

    (@webcraftic)

    Hi,

    Plugin docs:
    http://woody-ad-snippets.webcraftic.com/getting-started-with-woody-ad-snippets/

    How to work with Ajax in WordPress:
    https://www.smashingmagazine.com/2011/10/how-to-use-ajax-in-wordpress/

    1. You must create php snippet. Snippet should be running everywhere.
    2. Paste the Ajax action code into the snippet entry field and save the snippet.
    3. Now you can make ajax requests using javascript.

    I understand that you need more detailed instructions, but it is not. Ask more specific questions, I will try to answer.

    Best regards, Alex

    Thread Starter alfredobenni

    (@alfredobenni)

    This is my script Named “Orologio”. [wbcr_snippet id=”295″] in my WordPress.
    <script>
    var data = new Date();
    data.setTime(<? echo time()*1000; ?>);
    <? require(“funzione”); ?>
    function orologio()
    {

    var sec = data.getSeconds();
    document.getElementById(‘orologio’).innerHTML = sec;
    data.setTime(data.getTime()+1000)
    setTimeout(“orologio();”,1000);
    if(sec==0)
    {
    // “routine 1 to open snippet PHP”;
    document.getElementById(‘scritta’).innerHTML = ‘lancio routine 1 di apertura file in PHP’;
    echo do_shortcode(‘[wbcr_snippet id=”291″ title=”legge_101″]’); // ?????? this is wrong ?
    }
    if(sec==30)
    {
    // “routine 2 to open snippet PHP”;
    document.getElementById(‘scritta’).innerHTML = ‘lancio routine 2 di apertura file in PHP’;
    echo do_shortcode(‘[wbcr_snippet id=”291″ title=”legge_101″]’); // ????? this is wrong ?
    }
    }
    </script>
    <body onload=”orologio()”>
    <div id=”orologio”></div>
    <div id=”scritta”></div>
    </body>

    This is my PHP program. Name “legge_101”. [wbcr_snippet id=”291″] in My WordPress
    <?php

    $filename = “/tmp/utente101.txt”;
    $handle = fopen($filename, “r”);
    $img101 = fread($handle, filesize($filename));
    fclose($handle);
    // echo ‘call 899886011‘,”\n <br />”;
    // echo $img101;

    if($img101==”https://mysite.com/wp-content/uploads/2019/03/profilo_101_3.png&#8221;)
    {
    echo ‘‘,”\n <br />”;
    }
    else
    {
    echo ‘‘,”\n <br />”;
    }

    ?>

    the clock (“Orologio”) script must call the php script every 30 seconds
    thanks for the answers

    Thread Starter alfredobenni

    (@alfredobenni)

    I just don’t understand if I have to do the Ajax call, and (if needed) how to make the Ajax call.
    Where do I insert the PHP file to call with Ajax? In a snippet? How do I call him?
    I’m confused

    Thread Starter alfredobenni

    (@alfredobenni)

    The purpose of all this is to continuously update the images contained on the site.
    I have a control panel where the admin changes the images with status: On, OFF, Pause, Offline, etc …
    I want the site to present to the user the images updated every X seconds.
    The image to be uploaded is saved in the file “/tmp/utente101.txt”

    Thread Starter alfredobenni

    (@alfredobenni)

    Hi, I created a test program to use Ajax
    This is my script file that transmits data with Ajax. I get a weird result because the call is not correct. The program runs but looks for the test.php page and makes a mistake.
    I believe the script is still executed regardless of the name. And I don’t understand how to hook php script and php script name. javascript:xmlhttpPost(‘prova.php’), returns a wrong answer.

    The link:
    https://tarocchidelpotere.com/test/

    Program PHP “prova”: Run everywhere
    <?php
    //*Script Programmatore PHP
    $tuo_nome = $_POST[‘nome’];
    echo “<p>Hello $tuo_nome, how are you ?</p>”;
    ?>

    Program script: [wbcr_snippet id=”380″]
    <script language=”Javascript”>
    //Funzione per la gestione asincrona AJAX
    function xmlhttpPost(strURL) {
    //Inizializzo l’oggetto xmlHttpReq
    var xmlHttpReq = false;
    var self = this;
    // qui valutiamo la tipologia di browser utilizzato per selezionare la tipologia di oggetto da creare.
    // Se sono in un browser Mozilla/Safari, utilizzo l’oggetto XMLHttpRequest per lo scambio di dati tra browser e server.
    if (window.XMLHttpRequest) {
    self.xmlHttpReq = new XMLHttpRequest();
    }
    // Se sono in un Browser di Microsoft (IE), utilizzo Microsoft.XMLHTTP
    //che rappresenta la classe di riferimento per questo browser
    else if (window.ActiveXObject) {
    self.xmlHttpReq = new ActiveXObject(“Microsoft.XMLHTTP”);
    }
    //Apro il canale di connessione per regolare il tipo di richiesta.
    //Passo come parametri il tipo di richiesta, url e se è o meno un operazione asincrona (isAsync)
    self.xmlHttpReq.open(‘POST’, strURL, true);

    //setto l’header dell’oggetto
    self.xmlHttpReq.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);

    /* Passo alla richiesta i valori del form in modo da generare l’output desiderato*/
    self.xmlHttpReq.send(recuperaValore());

    /* Valuto lo stato della richiesta */
    self.xmlHttpReq.onreadystatechange = function() {

    /*Gli stai di una richiesta possono essere 5
    * 0 – UNINITIALIZED
    * 1 – LOADING
    * 2 – LOADED
    * 3 – INTERACTIVE
    * 4 – COMPLETE*/

    //Se lo stato è completo
    if (self.xmlHttpReq.readyState == 4) {
    /* Aggiorno la pagina con la risposta ritornata dalla precendete richiesta dal web server.Quando la richiesta è terminata il responso della richiesta è disponibie come responseText.*/
    aggiornaPagina(self.xmlHttpReq.responseText);
    }
    }
    }
    /*Questa funzione recupera i dati dal form.*/
    function recuperaValore() {
    var form = document.forms[‘form’];
    var nome = form.nome.value;
    valore = ‘nome=’ + escape(nome);
    return valore;
    }
    /*Questa funzione viene richiamata dall’oggetto xmlHttpReq per l’aggiornamento asincrono dell’elemento risultato*/
    function aggiornaPagina(stringa){
    document.getElementById(“risultato”).innerHTML = stringa;
    }
    </script>
    <!– Questo è il form, ad ogni submit del forum viene richiamata la funzione xmlhttpPost che ha come argomento il file esempio_ajax che esamineremo successicamente. –>
    <form name=”form” onSubmit=”javascript:xmlhttpPost(‘prova.php’); return false;”>
    <p>What’s your name?
    <input name=”nome” type=”text”>
    <input value=”Invia” type=”submit”>
    </p>
    <div id=”risultato”></div>
    </form>

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Run PHP temporized or Run PHP from Javascript temporized’ is closed to new replies.