JQuery IE8 $ (document) .ready "expected object" error

I'm having a problem with IE8 throwing the "expected object" when loading the page with the jquery $(document).ready() command. I looked through all the other entries that I can find here on SO, and none of the solutions seem to work.

To troubleshoot, I created the following html, which works fine in Firefox and Chrome, but creates the "expected object" in the $(document).ready . Still:

  • I confirmed that it reaches the google jQuery file, and tried to access the local jquery.js file - the same thing.
  • I tried placing the script in <head> (I included it in the body to recreate the situation on the site I'm developing on)
  • I also tried this with jQuery(document) instead of $ - same result
  • Inclusion: var $j=jQuery.noConflict(); and including $j(document) , getting jQuery undefined error in $j declaration.

What am I missing? ANY help is appreciated! Thanks!

 <html> <head> <script type="application/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script> </head> <body> <script type="text/javascript"> $(document).ready(function(){ alert("WORKING!"); }); </script> <div id="test"> </div> </body></html> 
+4
source share
4 answers

Mate, check out the two script tags. One says type="application/javascript" , the other says type="text/javascript" .

Change the first to type="text/javascript" and it will work fine.

+9
source

There was the same problem. I fixed it by fighting for a long time and tried a bunch of thinkers who did not work. But this work :)

Check the jquery script tag. If it contains type = "text / javascript" like this

 <script type="text/javascript" src="~/scripts/jquery-1.9.0.js"></script> 

then replace "text / javascript" with only "javascript"

 <script type="javascript" src="~/scripts/jquery-1.9.0.js"></script> 

Really vierd behavior, but it works. If anyone has a good explanation, please write an answer to this question.

NB! This only works for IE8, not Chrome or Firefox!

+4
source

Just ran into this error.

The problem for my part was pretty dumb: I ran Internet Explorer on a virtual machine. This computer did not have access to the Internet, but only on the host system where I had a web server. Therefore, external script links could not be resolved, of course.

+2
source

It helped me replace

 type="text/javascript" 

in

 language="javascript" 
0
source

All Articles