Make sure we have a fallback when XMLHttpRequest is manually disabled. Fixes #6298.
This commit is contained in:
parent
0368606c08
commit
873c28425f
32
src/ajax.js
32
src/ajax.js
|
@ -180,18 +180,9 @@ jQuery.extend({
|
||||||
password: null,
|
password: null,
|
||||||
traditional: false,
|
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
|
// This function can be overriden by calling jQuery.ajaxSetup
|
||||||
xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
|
xhr: function() {
|
||||||
function() {
|
|
||||||
return new window.XMLHttpRequest();
|
return new window.XMLHttpRequest();
|
||||||
} :
|
|
||||||
function() {
|
|
||||||
try {
|
|
||||||
return new window.ActiveXObject("Microsoft.XMLHTTP");
|
|
||||||
} catch(e) {}
|
|
||||||
},
|
},
|
||||||
accepts: {
|
accepts: {
|
||||||
xml: "application/xml, text/xml",
|
xml: "application/xml, text/xml",
|
||||||
|
@ -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?
|
// Does this browser support XHR requests?
|
||||||
jQuery.support.ajax = !!jQuery.ajaxSettings.xhr();
|
jQuery.support.ajax = !!jQuery.ajaxSettings.xhr();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue