Skip to content
Permalink
Browse files

Try to use XMLHttpRequest in more cases in IE 7. Thanks to Matt Kruse…

… and Sam Collett for the suggestions. Fixes #3623, #2849, #5338, and #5529.
  • Loading branch information
jeresig committed Jan 5, 2010
1 parent 25ee9ce commit b2289f3ec174c5b22d130d8c36a5e07daa6d02df
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/ajax.js
@@ -175,12 +175,13 @@ jQuery.extend({
traditional: false,
*/
// Create the request object; Microsoft failed to properly
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
// 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: function() {
return window.ActiveXObject ?
new ActiveXObject("Microsoft.XMLHTTP") :
new XMLHttpRequest();
return window.XMLHttpRequest && window.location.protocol !== "file:" || window.ActiveXObject ?
new window.XMLHttpRequest() :
new window.ActiveXObject("Microsoft.XMLHTTP");

This comment has been minimized.

Copy link
@kangax

kangax Jan 5, 2010

It would be a good idea to wrap this with try-catch, and also check other MSXML versions — "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP.6.0"

},
accepts: {
xml: "application/xml, text/xml",

2 comments on commit b2289f3

@jeresig

This comment has been minimized.

Copy link
Member Author

jeresig replied Jan 5, 2010

@kangax: Looks like you missed the next commit. 3f648c4

@kangax

This comment has been minimized.

Copy link

kangax replied Jan 6, 2010

Yep, that commit appeared in my feed shortly after I posed this comment.

Please sign in to comment.
You can’t perform that action at this time.