mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Merge pull request #693 from O-Zone/master
Added XDomainRequest as fallback method for ajax, if XMLHttpRequest f…
This commit is contained in:
commit
537eb83e34
@ -2045,10 +2045,42 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
|||||||
|
|
||||||
request.onreadystatechange = function(){};
|
request.onreadystatechange = function(){};
|
||||||
|
|
||||||
|
if (window.XDomainRequest) { // IE9 or IE8 might as well try to use XDomainRequest
|
||||||
|
var xdr = new XDomainRequest();
|
||||||
|
if (xdr) {
|
||||||
|
xdr.onload = function (e) {
|
||||||
|
if ( $.isFunction( onSuccess ) ) {
|
||||||
|
onSuccess({ // Faking an xhr object
|
||||||
|
responseText: xdr.responseText,
|
||||||
|
status: 200, // XDomainRequest doesn't support status codes, so we just fake one! :/
|
||||||
|
statusText: 'OK'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xdr.onerror = function (e) {
|
||||||
|
if ( $.isFunction ( onError ) ) {
|
||||||
|
onError({ // Faking an xhr object
|
||||||
|
responseText: xdr.responseText,
|
||||||
|
status: 444, // 444 No Response
|
||||||
|
statusText: 'An error happened. Due to an XDomainRequest deficiency we can not extract any information about this error. Upgrade your browser.'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
xdr.open('GET', url);
|
||||||
|
xdr.send();
|
||||||
|
} catch (e2) {
|
||||||
if ( $.isFunction( onError ) ) {
|
if ( $.isFunction( onError ) ) {
|
||||||
onError( request, e );
|
onError( request, e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( $.isFunction( onError ) ) {
|
||||||
|
onError( request, e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user