bg17aw bg17aw - 6 months ago 46
jQuery Question

Not able to load jQuery in Internet Explorer on localhost (WAMP)

I have a standard piece of HTML but cannot get jQuery to work on IE.
I tried IE10 and IE11, as well as IE8 and 9 emulated in IE10.

I even tried using the code from HTML5Boilerplate. I am testing for jquery and is not loaded.

Code works in all other browsers. I am running this on my local, not on a server.

<!DOCTYPE html>
<html>

<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>

<body>

<script type="text/javascript">
if (window.jQuery) {
// jQuery is available.
} else {
console.log("-- no jquery --");
}
</script>

</body>

</html>


Why can't I get this to work in IE ?

I get
-- no jquery -- SCRIPT5007: The value of the property '$' is null or undefined, not a Function object
in the console.

Also, if I type
jQuery().jquery
in the console, I get
undefined
.

Network tab is not displaying any errors.

Answer

Quote OP:

I am running this on my local, not on a server

Then you need to specify a scheme, otherwise the browser may assume that src="//domain.com/script.js" is src="file://domain.com/script.js", which will break since you're not hosting this resource locally.

References: