简体   繁体   English

通过AJAX替换整个页面仅导致IE中的权限被拒绝错误

[英]Replacing entire page via AJAX causes Permission Denied error in IE only

I have an AJAX post that retrieves data from the server and either replaces part of the page or in some cases the full page. 我有一个AJAX帖子,它从服务器检索数据,并替换了页面的一部分或在某些情况下替换了整个页面。 This is controlled by a javascript fullRefresh parameter. 这由javascript fullRefresh参数控制。 The problem is the refresh code works find in Firefox but causes a Permission Denied error in the bowels of JQuery after it runs in IE although it would appear to actually replace the page contents successfully. 问题是刷新代码可以在Firefox中找到,但是在IE中运行后,尽管JQuery似乎可以成功地替换页面内容,但在JQuery的肠道中会导致Permission Denied错误。

IE version 11.0.9600.16659 IE版本11.0.9600.16659

JQuery version 1.8.2 jQuery版本1.8.2

Error message
Unhandled exception at line 2843, column 3 in http://localhost:62761/Scripts/jquery-1.8.2.js

0x800a0046 - JavaScript runtime error: Permission denied

My code is 我的代码是

function RefreshScreenContent(formActionUrl, formHTML, fullRefresh) {

    fullRefresh = (typeof fullRefresh === "undefined") ? false : fullRefresh;

    if (fullRefresh) {
        document.write(formHTML);
        document.close();
    }
    else {
        $("#content-parent").html(formHTML);
    }


}

The partial refreshes work fine but the full refreshes are the problem. 部分刷新工作正常,但完整刷新是问题所在。 I have tried hardcoding the document.write call to write a well formed simple html page rather than formHTML in case that was somehow the problem but even a simple single word page causes the error. 我曾尝试对document.write调用进行硬编码,以编写格式正确的简单html页面,而不是formHTML,以防出现问题,但即使是单个单词页面也会导致错误。

The actual error occurs a some point later with a callback inside JQuery. 稍后在JQuery中使用回调会发生实际错误。

The AJAX post to the server is in the same application ie is not a cross domain request. 到服务器的AJAX发布在同一应用程序中,即不是跨域请求。 I have seen posts online talking aboue cross domain stuff that is not applicable here. 我已经看到网上发布有关跨域内容的帖子,但此处不适用。

Can anyone tell me why this is happening and how to stop it? 谁能告诉我为什么会这样以及如何阻止它? Is there an alternative IE way of replacing the page contents? 有替代页面内容的IE替代方法吗?

Your code is fine (at least at first glance). 您的代码很好(至少乍一看)。 My guess is that you make the call in such a way, that it is interpreted as cross-domain. 我的猜测是您以这种方式进行呼叫,即被解释为跨域。

I would suggest checking: 我建议检查:

  • http vs https (most common) http vs https(最常见)
  • the destination port 目的端口
  • the root url 根网址
  • maybe the "destination" page makes some requests of its own, check to be on same domain 也许“目的地”页面提出了一些自己的请求,请检查是否在同一域中

The reason why IE may be the only one with the problem is that it has higher security demanding by default that other browsers (check advanced security settings - can't remember where they are put in menu) so it interprets requests in a more "paranoid" manor. IE可能是唯一一个出现问题的原因是,默认情况下,它具有更高的安全性要求,即其他浏览器(检查高级安全性设置-无法记住它们在菜单中的位置),因此它以更“偏执”的方式解释请求庄园。

I repeat, what I said is just a guess, based on cases I've been put into. 我再说一遍,我所说的只是基于我所遇到的案例的猜测。

In the end I used the approach here to replace the body tag in the pgae with the one in the markup the AJAX receives back https://stackoverflow.com/a/7839921/463967 最后,我使用了这里的方法,将pgae中的body标签替换为AJAX收到的标记中的body标签https://stackoverflow.com/a/7839921/463967

I would have preferred to replace all content not just the body but I can always adapt later to include the header etc as body is enough for my uses right now. 我本来希望替换所有内容,而不仅是正文,但我以后总是可以修改以包括标头等,因为正文现在足以满足我的使用。 This works in IE and Firefox. 这适用于IE和Firefox。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM