Skip to main content

Bug Tracker

Side navigation

#14475 closed bug (fixed)

Opened October 21, 2013 02:29PM UTC

Closed November 14, 2013 09:16PM UTC

Last modified January 30, 2014 12:19PM UTC

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:
Description

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() || createActiveXHR();

} :

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]

Attachments (0)
Change History (7)

Changed October 21, 2013 03:32PM UTC by dmethvin comment:1

component: unfiledajax
priority: undecidedlow
status: newopen

See also #14424.

Changed October 21, 2013 04:09PM UTC by dmethvin comment:2

owner: → jaubourg
status: openassigned

Changed November 11, 2013 05:13PM UTC by dmethvin comment:3

owner: jaubourgdmethvin

Changed November 14, 2013 08:33PM UTC by dmethvin comment:4

milestone: None1.11

Changed November 14, 2013 09:16PM UTC by dmethvin comment:5

Changed December 02, 2013 03:51PM UTC by timmywil comment:6

#14589 is a duplicate of this ticket.

Changed January 30, 2014 12:19PM UTC by aconsolati@gmail.com comment:7

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