You entered the name correctly here. The experience is quite controversial. Let it go through him ...
var xdr, err, res, foo, url; xdr = new XDomainRequest(); err = function(){ alert("There was an error, operation aborted"); } res = function(){ alert("Success! " + xdr.responseText); } foo = function(){ return; } url = "http://hello.com/here/is/the/url/?query=true&whatever=asd"; xdr.onerror = err; xdr.ontimeout = foo; xdr.onprogress = foo; xdr.onload = res; xdr.timeout = 5000; xdr.open("get", url); xdr.send(null);
The XDomainRequest object is handled differently in each IE.
In IE9 โ, the XDomainRequest object requires that all descriptors be given a method. A value that treats as onerror, onload, ontimeout, and onprogress is all something you need to do. Without defining a method for these descriptors, you will receive a network response "operation aborted."
In IE7 / 8/9 โ XDomainRequest, the default is ASYNC. It will execute the code further down the stack, regardless of whether the xdr object terminated or not. Setting setTimeout may be a solution, but it should not.
In this case, activate the event and listen to the event before executing any additional code. An example of this might be (in jquery) ...
// call this method in xdr onload $(document).trigger("xdr_complete"); // use this wrapper in code you want to execute after the complete of xdr $(document).bind("xdr_complete", function(){ ... });
In IE7 / IE8 you will notice that it works. IE7 and IE8 are pretty "free" in the sense that they are not interrupted when there is no method for descriptors.
Erik5388
source share