Ben Ben - 1 year ago 289
jQuery Question

jQuery ajax request - IE11 Access is denied

The question

I'm making an ajax request via jQuery using the following function:

function ajaxRequest(requestName,responseFunction,parameters) {
console.log('Making request ' + requestName);
var now = new Date();
type: "GET",
url: "ajax.php",
error: function(jqXHR,textStatus,errorThrown ) {
console.log('Error: ' + textStatus + ' ' + errorThrown);
success:function(msg) {
console.log('Success! ' + msg);

What possible reasons for an 'Access is denied' error are there here? Is there anything I can do to get a more meaningful error message?

More information...

I'm currently calling this function to save a value in an input field. This works in all tested browsers.

I also call this function from an onpaste event (i.e. ), to do the same job, and this is what is failing, but only in IE11. The error is just "Access is denied.".

Note that this is not a cross domain request, it is requesting a file in the same directory.

Tested in:

  • Mac + Safari

  • Mac + Chrome

  • WinXP + IE8

  • Win7 + IE9

  • Win 8 + IE10

  • in 8.1 + IE11 (the only one that causes the problem.)

Note that I've stripped out some irrelevant parts of the code, such as using the responseFunction and parameters variable.

Ben Ben
Answer Source

After a lot of research, the only solution I could come up with that works, was to use a setTimeout to cause the AJAX request to trigger after 1 millisecond, instead of instantly. I presume this is some bug in IE11, but hopefully this solution will be useful to someone.

In the end, I changed this code:


to this:

setTimeout( (function(params) {
    return function() {

Just to be clear, the first line of code worked in every browser tested, as far down as IE7, except for IE11.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download