XMLHttpRequest troubles



  • I'm having some troubles with the following code:
    @
    .pragma library

    var server_ip = "192.168.1.1"
    var server_port = "9876"

    function webdomo_get(path, callback){
    var http = new XMLHttpRequest();
    http.open("GET", "http://"+server_ip+":"+server_port+path, true);
    http.onreadystatechange = function(){
    if(http.readyState != http.DONE){
    return;
    }
    if(http.readyState == http.DONE && http.status == 200){
    var results = eval('('+http.responseText+')');
    callback(results);
    }
    }
    http.send();
    }@

    This request is fired by a timer every 3 sec.

    Here are my problems:

    1. Sometimes i notice the following error:
      QHttpNetworkConnectionChannel::_q_receiveReply() called without QHttpNetworkReply, 0 bytes on socket.
      and the timer that fires the request stops.

    2. I need a way to abort the request if the server doesn't respond

    3. Is possible that this code fires up two requests at the same time?

    Thanks



    https://bugreports.qt-project.org/browse/QTBUG-9315

    Request aborts itself after some time or you can use xmlhttprequest.abort().
    xmlhttprequest.timeout property doesn't work for me, it seems not implemented.

    Yes, it is possible.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.