Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#14475 closed bug (fixed)

Local Ajax requests don't work in IE 11 (ActiveXObject checking in jQuery fails)

Reported by: sergeyi Owned by: dmethvin
Priority: low Milestone: 1.11
Component: ajax Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:


When you open any HTML page locally (through the file:/// protocol) in IE 11 that uses $.ajax to load any local file an exception is ocurred "Access is denied". This happens only in IE 11 and only when you open HTML page locally, it applies to all jQuery versions.

jQuery has the following code to work with XMLHttpRequest in IE: =============================== jQuery.ajaxSettings.xhr = window.ActiveXObject ?

/* 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. */

function() {

return !this.isLocal && createStandardXHR()

} : For all other browsers, use the standard XMLHttpRequest object createStandardXHR;


Everything is good except one thing: IE11 handles "window.ActiveXObject" in a strange way. It still returns a function, but if you try to get its type "typeof(window.ActiveXObject)" it will return "undefined" (though in IE10 it returns "function"). So the statement "window.ActiveXObject ? true : false" in IE11 will always return false. That's why in IE11 "createStandardXHR" is always used, while createActiveXHR is never used (even locally). This causes a problem that any AJAX request to a file from locally opened HTML web page will fail with the error "Access is denied".

To fix the problem it's enough to change the condition: use "window.ActiveXObject !== undefined ?" instead of "window.ActiveXObject ?"

A couple of words about changes with ActiveXObject in IE 11 can be found here http://msdn.microsoft.com/en-us/library/ff955298(v=vs.85).aspx

Change History (7)

comment:1 Changed 10 years ago by dmethvin

Component: unfiledajax
Priority: undecidedlow
Status: newopen

See also #14424.

comment:2 Changed 10 years ago by dmethvin

Owner: set to jaubourg
Status: openassigned

comment:3 Changed 10 years ago by dmethvin

Owner: changed from jaubourg to dmethvin

comment:4 Changed 10 years ago by dmethvin

Milestone: None1.11

comment:5 Changed 10 years ago by dmethvin

Resolution: fixed
Status: assignedclosed

comment:6 Changed 9 years ago by Timmy Willison

#14589 is a duplicate of this ticket.

comment:7 Changed 9 years ago by aconsolati@…

This still does not seem to be working correctly in jquery-1.11.0.js with IE11. The original error "Access is Denied" is no longer returned, but the $.get function does not retrieve the local file contents.

A call such as the following will return "No Transport" in the .fail() callback:

$.get("file://c:/Temp/Master.tmpl.htm", function (templateContents) {

/* do something with templateContents; */

}, "html").fail(function (jqXHR, textStatus) {

/* error will contain "No Transport" */ var error = jqXHR.statusText;


Whereas using "c:/Temp/Master.tmpl.htm" as the path (without the file:// protocol) results in $.get not invoking any callbacks and just skipping to the next line of code.

Are there any examples of how to use $.get to successfully retrieve the contents of a local file in IE11?

Many thanks

Note: See TracTickets for help on using tickets.