JQuery ajax request - IE11 access denied

Question

I am making an ajax request through jQuery using the following function:

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

      

What are the possible reasons for the Access Denied error here? Is there anything I can do to get a more meaningful error message?

Additional Information...

I am currently calling this function to store the value in an input field. This works in all tested browsers.

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

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

Tested:

  • Mac + Safari
  • Mac + Chrome
  • WinXP + IE8
  • Win7 + IE9
  • Win 8 + IE10
  • in 8.1 + IE11 (the only one that's causing the problem.)

Note that I have removed some irrelevant parts of the code, for example using the responseFunction variable and parameters.

+3


source to share


1 answer


After a lot of research, the only solution I could come up with was to use setTimeout to make the AJAX request fire in 1 millisecond rather than instantly. I am guessing this is some bug in IE11, but hopefully this solution will be helpful to someone.

In the end, I changed this code:

ajaxRequest('save_function','response_function',params);

      



:

setTimeout( (function(params) {
    return function() {
        ajaxRequest('save_function','update_save_marksheet_mark',params);
    };
})(params),1);

      

To be clear, the first line of code worked in every browser I tested, up to IE7, with the exception of IE11.

+6


source







All Articles