diff options
author | John Resig <jeresig@gmail.com> | 2010-09-28 10:12:33 -0700 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2010-09-28 10:12:33 -0700 |
commit | 873c28425fb64fdb48cfa09d17041bded39b301f (patch) | |
tree | 363d5b8627bb4f83d26dffffb2aa8720b888af69 /src/ajax.js | |
parent | 0368606c081fd15dfbcd8509734ef63c58a6b008 (diff) | |
download | jquery-873c28425fb64fdb48cfa09d17041bded39b301f.tar.gz jquery-873c28425fb64fdb48cfa09d17041bded39b301f.zip |
Make sure we have a fallback when XMLHttpRequest is manually disabled. Fixes #6298.
Diffstat (limited to 'src/ajax.js')
-rw-r--r-- | src/ajax.js | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/ajax.js b/src/ajax.js index 31efc566f..e61548068 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", @@ -695,6 +686,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(); |