Skip to content

Commit 3f648c4

Browse files
committed
Make sure that the ActiveX exception is caught if it's unable to be loaded. Fixes #2849.
1 parent b2289f3 commit 3f648c4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/ajax.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,14 @@ jQuery.extend({
179179
// so we use the ActiveXObject when it is available
180180
// This function can be overriden by calling jQuery.ajaxSetup
181181
xhr: function() {
182-
return window.XMLHttpRequest && window.location.protocol !== "file:" || window.ActiveXObject ?
183-
new window.XMLHttpRequest() :
184-
new window.ActiveXObject("Microsoft.XMLHTTP");
182+
if ( window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ) {
183+
return new window.XMLHttpRequest();
184+
185+
} else {
186+
try {
187+
return new window.ActiveXObject("Microsoft.XMLHTTP");
188+
} catch(e) {}
189+
}
185190
},
186191
accepts: {
187192
xml: "application/xml, text/xml",
@@ -326,6 +331,10 @@ jQuery.extend({
326331
// Create the request object
327332
var xhr = s.xhr();
328333

334+
if ( !xhr ) {
335+
return;
336+
}
337+
329338
// Open the socket
330339
// Passing null username, generates a login popup on Opera (#2865)
331340
if ( s.username ) {

0 commit comments

Comments
 (0)