4

I am getting permission denied error on IE (firefox it works fine)

I am making an ajax call (local domain) and result of the call I am assigning to a div. On debugging I came to know there is no issue with ajax call and variable 'result' has the result data. Error is thrown when data is being assigned to div.

Error Line: 2 jquery-1.8.1.min.js Error: Permission denied

Javascript code:

$.get('administration.htm', function (result) {
    $('#adminDiv').find('#content').html(result);
});

Any idea why this error is coming.

10
  • maybe this helps: stackoverflow.com/a/2960963/953684
    – Sharky
    Jul 1, 2013 at 11:37
  • I already have meta tag defined in head tag.
    – lav mudgal
    Jul 1, 2013 at 11:43
  • is the target div in an iframe?
    – Sharky
    Jul 1, 2013 at 11:47
  • instead of using $('#adminDiv').find('#content').html(result) I tried to change it to document.getElementById('content').innerHTML=result; Now i am not getting this error but events defined on result does not work and even formatting is not correct.
    – lav mudgal
    Jul 1, 2013 at 11:47
  • no, target div is not in an iframe
    – lav mudgal
    Jul 1, 2013 at 11:50

1 Answer 1

2

The permission denied error could be coming from trying to manipulate the DOM before the document is ready.

As for the events and formatting no longer working, using JavaScript and jquery to select things can cause issues. When you use document.getElementById it will update the DOM and the rendered page but it will not update the associated jQuery objects. To solve this you either need to re-generate the jQuery object (using $('selector')) and reattach the handlers or try something like $(document.getElementById('objectId')).html('result'); where you use javascript to find the DOM element to avoid the permission error then modify it using the associated jQuery object.

2
  • I doubt attempting to acces elements before they have been loaded produces Error: Permission denied. And document.getElementById does not update the DOM. What do you think it changes?
    – Oriol
    Sep 26, 2016 at 22:49
  • Hi @Oriol. Trying to access dom elements before they are loaded definitely will cause this error in some browsers. In my answer I was referring to manipulating the DOM using the objects returned by document.getElementById and $('selector') not the functions themselves.
    – Dion
    Sep 27, 2016 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.