views:

36

answers:

0

I'm experiencing an issue with XMLHttpRequest. If there is no Internet connection, my request is not timing out and thus freezing the browser. Here is the request code:

 var jsonData = new XMLHttpRequest();
 jsonData.open('GET', urltest, false);
 jsonData.Timeout = 100;
 jsonData.send(null);
 if(jsonData.status == 200) {
     alert(jsonData.statusText);
 }else{
     alert(jsonData.statusText);
 }

How do I abort the request if the server doesn't respond?