Skip to content Skip to sidebar Skip to footer

Need Xml Data To Keep POST-ing Every 2 Seconds Until A Response Is Received

This is a very small application for a prototype/experiment. A device is going into sleep every so often to save battery life and a user will access a local webpage and press a but

Solution 1:

I suggest looking at socket.io to "ping" the device in a loop until it wakes up, THEN send the POST request.


Solution 2:

have you considered to use jquery?

function ping () {
    $.ajax (
          <url>
        , {
              error:    function ( jqXHR, textStatus, errorThrown ) {
                        }
            , timeout:  5000    // in ms
            , type:     'POST'
          }
    }).done(function ( data, textStatus, jqxhr ) {
        // whatever
    }).fail(function ( jqxhr, textStatus, data ) {
        // note that the order of arguments is different from that of the success handler ('done') !
        if (textStatus === 'timeout') {
            ping();
        }
        else {
            // ... more error handling
        }
    });

for more info, consult the docs.


Post a Comment for "Need Xml Data To Keep POST-ing Every 2 Seconds Until A Response Is Received"