July 10, 2012

rferrazz rferrazz
Lab Rat
20 posts

XMLHttpRequest troubles

 

I’m having some troubles with the following code:

  1. .pragma library
  2.  
  3. var server_ip = "192.168.1.1"
  4. var server_port = "9876"
  5.  
  6. function webdomo_get(path, callback){
  7.     var http = new XMLHttpRequest();
  8.     http.open("GET", "http://"+server_ip+":"+server_port+path, true);
  9.     http.onreadystatechange = function(){
  10.                 if(http.readyState != http.DONE){
  11.                     return;
  12.                 }
  13.                 if(http.readyState == http.DONE && http.status == 200){
  14.                     var results = eval('('+http.responseText+')');
  15.                     callback(results);
  16.                 }
  17.             }
  18.     http.send();
  19. }

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

1 reply

July 11, 2012

giovannie giovannie
Lab Rat
14 posts

1.

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

2.

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

3.

Yes, it is possible.

 
  ‹‹ [Solved] TextInput overwriteMode      Fickable + TextField + InputContext ››

You must log in to post a reply. Not a member yet? Register here!