Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
154
rated 0 times [  159] [ 5]  / answers: 1 / hits: 50001  / 14 Years ago, wed, june 2, 2010, 12:00:00

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.



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 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?



edit:
A small example:



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 );
});
});
});


Try it here: http://t1318.greatnet.de/ietest/test.html


More From » jquery

 Answers
14

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>

[#96605] Monday, May 31, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
keana

Total Points: 452
Total Questions: 97
Total Answers: 81

Location: Barbados
Member since Sun, Nov 27, 2022
2 Years ago
;