Skip to content

Commit

Permalink
Try to use XMLHttpRequest in more cases in IE 7. Thanks to Matt Kruse…
Browse files Browse the repository at this point in the history
… and Sam Collett for the suggestions. Fixes #3623, #2849, #5338, and #5529.
  • Loading branch information
jeresig committed Jan 5, 2010
1 parent 25ee9ce commit b2289f3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ajax.js
Expand Up @@ -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",
Expand Down

2 comments on commit b2289f3

@jeresig
Copy link
Member Author

@jeresig jeresig commented on b2289f3 Jan 5, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@kangax
Copy link

@kangax kangax commented on b2289f3 Jan 6, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.