I'm experiencing some timeouts with a synchronous XML HTTP request in Safari on my Mac. In an attempt to fix this issue, I added a timeout setting like this:
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; //It seems the timeout cannot be set here
req.send(params); //Without the above line, a timeout occurs in Safari
After adding the .timeout = 60000, I encountered a timeout during the .send operation.
Upon setting the .timeout=60000, I received an error stating "XMLHttpRequest.timeout cannot be set for synchronous http(s) requests made from the window context."
I'm unsure about the meaning of "XMLHttpRequest.timeout cannot be set for synchronous http(s) requests made from the window context." I also came across a similar statement in Mozilla's documentation:
Note: You may not use a timeout for synchronous requests with an owning window.
Is there a solution to this problem? The MSDN website mentions the following 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