X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax.js;h=08dc4431a7e9b9d40d624d9f24323183495b9781;hb=d2e64979bf641181443a8e6456f6292973a7fa9a;hp=31efc566f0a9f236df071333f9842484972baa0a;hpb=e63fa8beb8e285fe19fc0a1557045b80e3c63c66;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index 31efc56..08dc443 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -180,19 +180,10 @@ jQuery.extend({ password: null, traditional: false, */ - // Create the request object; Microsoft failed to properly - // implement the XMLHttpRequest in IE7 (can't request local files), - // so we use the ActiveXObject when it is available // This function can be overriden by calling jQuery.ajaxSetup - xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ? - function() { - return new window.XMLHttpRequest(); - } : - function() { - try { - return new window.ActiveXObject("Microsoft.XMLHTTP"); - } catch(e) {} - }, + xhr: function() { + return new window.XMLHttpRequest(); + }, accepts: { xml: "application/xml, text/xml", html: "text/html", @@ -467,12 +458,14 @@ jQuery.extend({ } }; - // Override the abort handler, if we can (IE doesn't allow it, but that's OK) + // Override the abort handler, if we can (IE 6 doesn't allow it, but that's OK) // Opera doesn't fire onreadystatechange at all on abort try { var oldAbort = xhr.abort; xhr.abort = function() { - if ( xhr ) { + // xhr.abort in IE7 is not a native JS function + // and does not have a call property + if ( xhr && oldAbort.call ) { oldAbort.call( xhr ); } @@ -695,6 +688,27 @@ jQuery.extend( jQuery.ajax, { }); +/* + * Create the request object; Microsoft failed to properly + * implement the XMLHttpRequest in IE7 (can't request local files), + * so we use the ActiveXObject when it is available + * Additionally XMLHttpRequest can be disabled in IE7/IE8 so + * we need a fallback. + */ +if ( window.ActiveXObject ) { + jQuery.ajaxSettings.xhr = function() { + if ( window.location.protocol !== "file:" ) { + try { + return new window.XMLHttpRequest(); + } catch(e) {} + } + + try { + return new window.ActiveXObject("Microsoft.XMLHTTP"); + } catch(e) {} + }; +} + // Does this browser support XHR requests? jQuery.support.ajax = !!jQuery.ajaxSettings.xhr();