I'm getting some timeouts on a synchronous xml http request in Safari on a Mac. As a workaround, I tried adding a timeout like so:

    req.open(this.method, fullURL, this.isAsync);
    req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

    var params = this.envelopeForm();
    req.setRequestHeader("Content-length", params.length);
    req.timeout = 60000;  //Get the timeut cannot be set here
    req.send(params);  //Without the above, get a timeout here in Safari

With the .timeout = 60000 I'm getting a timeout on the .send.

With the .timeout=60000, I'm getting the "XMLHttpRequest.timeout cannot be set for synchronous http(s) requests made from the window context."

I'm not clear on what "XMLHttpRequest.timeout cannot be set for synchronous http(s) requests made from the window context" means. I also found it in mozilla's documentation phrased like so:

Note: You may not use a timeout for synchronous requests with an owning window.

Is there a work-around for this? On the MSDN site I found the following statement regarding Internet Explorer:

If you set an XMLHttpRequest time-out value that is larger than the network stack's time-out value, the network stack will time out first and the ontimeout event will not be raised

-Eric

1

There are 1 best solutions below

0
On

timeout with synchronous ajax requests can only be used from web workers