问题描述
我尝试做一个AJAX调用jQuery和 $。在Internet Explorer中交
,但我得到的是一个错误说权限被拒绝。现在的问题是有点儿奇怪,因为当我访问一个页面后,我在任何其他网页只发生。
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.
比如我输入的联系地址线的网址,让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论坛的,你必须有内容类型元在你的头标记的第一个项目。
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>
这篇关于&QUOT;拒绝权限&QUOT;使用Internet Explorer和jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!