...

View Full Version : Get Error 'jQuery' is undefined - did I fix it?



listerdl
07-05-2012, 06:26 PM
In IE9 I tested my site and there is a "helpful" box that pops up saying that there is an error on the page.

The error I got was "Get Error 'jQuery' is undefined"

So after some research I read that the fix (http://stackoverflow.com/questions/6923779/get-error-jquery-is-undefined) is to include the JQuery link (either through the Google CDN or otherwise).

So, I pasted that in the code and the error has gone. I guess I have fixed it but I don't really understand what I have done - I mean, did another javascript request the jquery and now all is good?

I guess if it works it works but id like to understand how I fixed it.

Thanks

(I should add that I know virtually nothing about javascript, rather my contribution to the site was html and css/ design etc.).

WolfShade
07-05-2012, 06:51 PM
jQuery is a JavaScript library (a very handy one) that has to have a "source" of jQuery to work. You can either download it and include it locally, or you can access it via the Google CDN. Either way, without that "source", jQuery is undefined.

listerdl
07-05-2012, 06:53 PM
ok thanks

let me ask you though - does it do any harm if the reference to this was there but not used or needed? Or said another way, is there an argument to include it when you have other javascripts at play (in case one does actually need it)?

I am referring to this:


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

Thanks

WolfShade
07-05-2012, 06:58 PM
I think it depends upon whom you ask. Basically the jQuery code will be loaded with every page load. Since it is minified, it's not a TON of code. But some are "efficient" minded, and even the scant milliseconds that it takes to load if it's not going to be used are too much.

So.. it's really a matter of preference, IMHO.

listerdl
07-05-2012, 07:18 PM
ok so if the jquery was not needed but was pulled into the page it wouldn't do any harm?

Could there be a javascript conflict if jquery was requested but not required? Thanks

WolfShade
07-05-2012, 07:28 PM
ok so if the jquery was not needed but was pulled into the page it wouldn't do any harm? Correct.


Could there be a javascript conflict if jquery was requested but not required? Thanks I'm not sure I understand your question.

listerdl
07-05-2012, 07:30 PM
thanks - the first bit of my question and the second bit are basically the same so thanks for helping.

Good to know that



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum