Safe cleanup in makeAjaxRequest error handler

Previously `request.onreadystatechange` was assigned an empty function
on success but null on failures, which breaks in IE (see
http://jsbin.com/ezozax/6/).

This patch simply mimics the success behaviour in the cleanup function

Closes #143
This commit is contained in:
Chris Adams 2013-06-25 14:12:29 -04:00
parent 9cbda1bd8f
commit f2cba16a8b

View File

@ -1335,6 +1335,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
if ( options.async ) { if ( options.async ) {
/** @ignore */ /** @ignore */
request.onreadystatechange = function() { request.onreadystatechange = function() {
// 4 = DONE (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#Properties)
if ( request.readyState == 4) { if ( request.readyState == 4) {
request.onreadystatechange = function(){}; request.onreadystatechange = function(){};
options.success( request ); options.success( request );
@ -1352,7 +1353,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
e.message e.message
); );
request.onreadystatechange = null; request.onreadystatechange = function(){};
request = null; request = null;
if ( options.error && $.isFunction( options.error ) ) { if ( options.error && $.isFunction( options.error ) ) {