2

I am getting this error when i run my webpage in IE(the code runs fine in other browsers).

This is the HTML code:

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</head>
<body>
<--- some html code --->
<iframe src='http://localhost/page1.php' style="background: transparent; overflow: hidden; height: 210px; width: 390px;" frameborder="0"  />
</body>
</html>

This is page1.php

<!DOCTYPE html>
<html>
<body>
<form action="usercheck.php" method="POST">
USERNAME:<input name="uname" id="uname" type="text" maxlength="12" required/>
<input type="submit" value="Submit">
</form>
</body>
</html>

This is usercheck.php

<?php
//some php code    
?>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</head>
<body>
<--- some html code --->
</body>
</html>

The problem is that when reach usercheck.php after clicking on submit button in page1.php i get the error http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js. Access is denied. Here is an image of the error: http://i.stack.imgur.com/diCoF.jpg . Then consequently i get the error that '$' symbol is not defined(which is due to the failure to load the jquery library).

EDIT- I have tried including the jquery file in my server but still the error is comming. I have also tried this code for usercheck.php:

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
/*! jQuery v1.10.1 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
//@ sourceMappingURL=jquery.min.map
//and the rest of the jquery library...
</script>
</head>
<body>
<--- some html code --->
</body>
</html>

The error i am getting this time is this:http://i.stack.imgur.com/hR9aN.jpg (The original name of usercheck2.php is rscheck.php in my server). Then consequently i get the error that '$' symbol is not defined(which is due to the failure to load the jquery library). If i directly open the contents of page1.php (by the url- localhost/page1.php) then everything works fine.

This is the only code for which i am using JQuery:

if($("#pret").contents().text().search("NAMECHECK: NOTAVALIBLE")!=-1)

I could exclude jquery only if i can convert this code to javascript.

Richard Ev
  • 48,781
  • 54
  • 181
  • 273
Sid
  • 470
  • 1
  • 6
  • 19

4 Answers4

6

This is a legit jQuery 1.10.1 bug: http://bugs.jquery.com/ticket/13980 .
Using jQuery 1.10.0, or 1.10.2 the error no longer occurs.

Emanuele Greco
  • 11,903
  • 7
  • 46
  • 69
0

Try to download jquery.min.js to your server and include it from there. For example:

<script type="text/javascript" src="/jquery.min.js"></script>.

It looks like internet explorer can't access the resource: downloading it to your own server might solve the issue.

Saturnix
  • 8,648
  • 13
  • 50
  • 103
0

Here is the working solution to my question. The reason i wanted jquery was that i wanted to run this code:

if($("#pret").contents().text().search("NAMECHECK: NOTAVALIBLE")!=-1)

I removed jquery library and used this javascript to do the same:

var n=document.getElementById("pret").innerHTML.search("NAMECHECK: NOTAVALIBLE");
if(n != -1)

Now there is no error in the page and i am able to do what i wanted. So the error was caused as jquery library was not able to load in the webpage. But i dont know why even after downloading the jquery library in my server i was getting the same error ie. 'Access is denied'.

Richard Ev
  • 48,781
  • 54
  • 181
  • 273
Sid
  • 470
  • 1
  • 6
  • 19
-1

The reason is in the iframe. As jQuery is loaded into the iframe from the external host, each time when you are trying to use any jQuery function in your main/outer html file, IE throws the error due to security reasons.

1) Either upload jQuery to your server,

2) or include it in main html file only (not in iframe).

Bakudan
  • 17,636
  • 9
  • 48
  • 69
Iurii.K
  • 2,739
  • 2
  • 13
  • 15
  • The error is when the iframe page tries to access the jquery library – Sid Jun 20 '13 at 13:02
  • Then the best way is to upload jQuery (and maybe other js files you use) to your server, so all of them are hosted on your end. – Iurii.K Jun 20 '13 at 13:05
  • Make sure that the locally hosted jQuery is included once, and try to include it in usercheck.php. – Iurii.K Jun 20 '13 at 13:16
  • i have copy pasted the library in the webpage itself and then also i am getting the same error. – Sid Jun 20 '13 at 13:20
  • hm.. maybe the answers here will be helpful for you http://stackoverflow.com/a/5087606/841675 – Iurii.K Jun 20 '13 at 14:31
  • no use, as the webpage is not able to load the jquery library so it will identify '$' symbol and will not interpret the code – Sid Jun 20 '13 at 16:03
  • i need an alternative javascript for finding a string in a div, not for this – Sid Jun 20 '13 at 17:06