jQuery load() throws “permission denied” error in IE

江枫思渺然 提交于 2020-04-07 06:34:18

问题


I'm loading a page through AJAX with jQuery's load() function. It doesn't work in IE8, giving the "permission denied" error. Using the IE debugger, it seems that when jQuery tries to open up the xhr, ie blocks it.

The problem is, my page has a javascript src that points to bing maps js api (which of course is in a completely different domain than mine). It seems to me that IE tries to grab this js file through a xhr, which then throws the "permission denied" error. Is there a workaround for this?

I can only remember of downloading the bing maps js myself and serving them locally.


回答1:


I did more test on this. And seems the error was caused by invalid HTML structures on the page. As it is a very complicated page, there are mismatched open <div> or <table> on the page, as when I shorten the page to bare minimum, it works on IE as well. But I don't understand why it was not working when you get to the page first time, and if you refresh the page, it will work after that.




回答2:


I just had this problem and I posted my solution on this thread:

jQuery AJAX problem in IE7 (possibly other versions as well)




回答3:


I eventually grabbed a copy of the script and include it myself, so it is in the same domain.




回答4:


You could include the script tag to the Bing Maps API in the parent document (the one making the jQuery load() call).




回答5:


Just for the reference:

I experienced this error on Windows 8 with IE 10 inside my WinForms application.

In this application, I'm hosting a WebBrowser control that loads its content from a built-in web server and also communicates via window.external with my host WinForms application.

Enough keyword fishing.

Getting this error

Now what happens to get this jQuery error in my application was:

  1. Browser has successfully loaded an URL.
  2. I programmatically loaded another URL.
  3. Then I immediately opened a child form with Form.ShowDialog.

After closing this form, the jQuery error was shown.

Resolving this error

I resolved the error by postponing the opening of the child form until the application was idle.

I.e. I used a Queue list inside my main form, subscribed to the Application.Idle event and inside this event handler, I processed the queue, one by one.

The new steps now were:

  1. Browser has successfully loaded an URL.
  2. I programmatically loaded another URL.
  3. Put the action to open the child form inside the idle queue.
  4. When the idle queue is processed, it opens the child form.

Then, the error was gone.

I guess, instead of using this idle processing, I also could have waited until the web browser finished its loading by subscribing to the DocumentCompleted event and show the child dialog from there.

Hope this will help someone...



来源:https://stackoverflow.com/questions/1954740/jquery-load-throws-permission-denied-error-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!