“权限被拒绝"使用 Internet Explorer 和 jQuery [英] "Permission denied" with Internet Explorer and jQuery

查看:34
本文介绍了“权限被拒绝"使用 Internet Explorer 和 jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 Internet Explorer 中使用 jQuery 和 $.post 进行 AJAX 调用,但我得到的只是一个错误,提示权限被拒绝".这个问题有点奇怪,因为它只在我访问任何其他页面后访问页面时发生.

I try to do an AJAX call with jQuery and $.post in Internet Explorer, but all I get is an error saying "Permission denied". The problem is kinda weird since it occurs only when I access a page after I was on any other page.

例如,我在地址行中输入 URL 并让 IE 加载页面.然后我单击一个按钮,以便脚本开始加载 JSON 数据.(提供数据的脚本位于同一台服务器上,我使用相对 URL 访问它,因此使用不同的域在这里不是问题.甚至尝试使用具有相同主机部分的绝对 URL.)

For instance I type the URL in the adress line and let IE load the page. Then I click on a button so the script should start loading JSON data. (The script providing the data lies on the same server and I access it with a relative URL, so using a different domain is not the problem here. Even tried to use a absolute URL with the same host part.)

但是当我刷新页面并再次尝试时它可以工作!当我从另一个页面来到那个页面时,同样的事情.起初没有任何效果,但是当我单击刷新"时一切正常.

But when I refresh the page then and try it again it works! Same thing when I come to that page from another page. At first nothing works, but when I click "refresh" everything is fine.

IE 给我错误消息权限被拒绝",而在所有其他浏览器中我没有注意到这种行为.由于我尝试了很多方法仍然无法想象问题出在哪里,我想请问您您认为问题是什么?

IE gives me the error message "Permission denied" while in every other browser I don't notice this behaviour. Since I have tried many things and still cannot imagine where the problem lies I'd like to ask you what you think the problem might be?

一个小例子:

test.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> 
    <head> 
        <script type="text/javascript" src="/ietest/jquery.js"></script> 
        <script type="text/javascript" src="/ietest/test.js"></script> 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    </head> 
    <body> 
        <a href="#">Test</a>
    </body> 
</html>

ajax.html

It works!

test.js

$(document).ready(function(){
    $( 'a' ).click(function(){
        $.post( '/ietest/ajax.html', function( data ) {
            alert( data );
        });
    });
});

在这里试试:http://t1318.greatnet.de/ietest/test.html

推荐答案

来自 jquerys 论坛上的帖子 此处,您必须将内容类型元作为 head 标记中的第一项.

From the post on jquerys forum here, you have to have the content type meta as the first item in your head tag.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> 
    <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript" src="/ietest/jquery.js"></script> 
        <script type="text/javascript" src="/ietest/test.js"></script>  
    </head> 
    <body> 
        <a href="#">Test</a>
    </body> 
</html>

这篇关于“权限被拒绝"使用 Internet Explorer 和 jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆