user2307211
user2307211

Reputation: 117

jQuery is undefined exception in IE11

In IE11 I get this exception

'jQuery' is undefined

I do not get this error in any other browser. The code that is causing the problem is

jQuery(document).ready(function(){

Any one know why is that and what might be causing the problem?

Upvotes: 6

Views: 23569

Answers (3)

buttercup
buttercup

Reputation: 1116

In IE11, depending on your security settings, access to external CDNs may be blocked.

Thus, you will have to add 2 JQuery URLs, one for (every other browser) and one locally.

// First try loading jQuery from Google's CDN
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

// Fall back to a local copy of jQuery if the CDN fails
<script>
window.jQuery || document.write('<script src="/js/jquery.min.js"><\/script>')
</script>

Reference: https://bugsnag.com/blog/jquery-is-not-defined-cause-solution

Upvotes: 6

GoldNeg
GoldNeg

Reputation: 1

First of all, check if 'jquery' package is installed or not. Then, you have to check the jquery version in the .js file you're referencing to, to be the same as your jquery files in 'Scripts'.

Upvotes: 0

Don D
Don D

Reputation: 754

I came across the same issue in Internet Explorer 11. It occurs due to compatibility mode is auto set to Internet Explorer 7. Image is attached.

I use jQuery 2.2 in my project. It seems to be that only IE9 and upwards support for this version.

Internet Explorer Compatibility List

To force the compatibility mode use below meta tag.

<meta http-equiv="X-UA-Compatible" content="IE=11" >

Upvotes: 6

Related Questions