Access denied JavaScript error in Internet Explorer

I get this error when I launch my webpage in IE (the code works 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 I reach usercheck.php after clicking the submit button in page1.php I get the error message http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js. Access is denied. http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js. Access is denied. Here is the error image: http://i.stack.imgur.com/diCoF.jpg . Then, therefore, I get an error that the "$" character is undefined (due to the inability to load the jquery library).

Edit- I tried including the jquery file on my server, but still an error is sent. I 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 get this time is: http://i.stack.imgur.com/hR9aN.jpg (Original usercheck2.php: rscheck.php on my server). Then, therefore, I get an error that the "$" character is undefined (due to the inability to load the jquery library). If I directly open the contents of page1.php (by url-localhost / page1.php), everything works fine.

This is the only code I'm using jQuery for:

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

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

+2
source share
4 answers

Here is a working solution on my question. The reason I wanted jquery was because I wanted to run this code:

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

I removed the 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 on the page, and I can do what I need. So the error was caused because the jquery library was not loaded on the web page. But I don’t know why even after loading the jquery library on my server I was getting the same error, that is. "Access is denied".

0
source

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

+6
source

Try downloading jquery.min.js to your server and enable it from there. For instance:

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

It seems that an Internet explorer cannot access the resource: uploading it to your own server may solve the problem.

0
source

The reason is iframe . Since jQuery is loaded into the iframe from an external host, every time you try to use some jQuery function in your main / external html file, IE throws an error due to security reasons.

1) Download jQuery to your server,

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

-1
source

Source: https://habr.com/ru/post/948415/


All Articles