If you pop open this page with your javascript console, you'll notice a bunch of JS errors. I don't get these errors in my local environment and it seems like it is happening because $ is not defined. I have tried to mimic my local environment exactly on staging by using the same environment.rb file and removing all JS caching but it is making no difference. Can anyone tell why jQuery is crapping out? It might be something really stupid, but I need a second pair of eyes.
+1
A:
Try reuploading it. From a freshly download copy from the jQuery site if you have to. It may be an encoding error or something like that.
It breaks for me.
Aaron Harun
2010-06-15 03:07:36
I tried loading it from google ajax libraries and it makes no difference.
Tony
2010-06-15 03:09:33
Try removing the other libraries one by one to see if another is conflicting or causing the error.
Aaron Harun
2010-06-15 03:17:41
wibya was the conflict!
Tony
2010-06-15 04:03:03
A:
You can try to load it from Google. I think it's a pretty good solution:
http://code.google.com/apis/ajaxlibs/documentation/#jquery
You can point to "latest" so it's always the latest version.
You will need an API key, which will be free. :)
Good luck,
Flavio
Flavio
2010-06-15 03:18:48
You don't need an api key to load jQuery from google's CDN. Just put a `<script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>` tag in.
Alex JL
2010-06-15 03:32:33
if you want to use the latest you will need it. Just read the site...http://code.google.com/apis/ajaxlibs/documentation/#IntroductionWarning: You need your own API key. In the example below, replace "INSERT-YOUR-KEY" with your own, unique key. Without your own key, these examples won't work. <script type="text/javascript" src="http://www.google.com/jsapi?key=INSERT-YOUR-KEY"></script>Next, you load the libraries is by using google.load() to name a library and your prefered version. E.g.: google.load("jquery", "1.4.2");
Flavio
2010-06-15 03:55:43
@Flavio - yes, you are correct on that, but you don't really need all that to load from google CDN... just `<script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>` will do... see it here, http://jsbin.com/
Reigel
2010-06-15 04:05:21
That is only if you want to use google.load. As they say, "Each library is available via both google.load() and directly, via <script/> tag". If you want the latest, in a normal script tag as I posted, you just specify the version as 1 or 1.4 rather than specifically as 1.4.2.
Alex JL
2010-06-15 04:07:29
+1
A:
It works for me. I don't know why, because you need to move
<script src="http://dev.betterhumanrace.com/javascripts/jquery.js?1276572679" type="text/javascript"></script>
to be above
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
in the source. You can't use $ before you've loaded the script that defines it.
Alex JL
2010-06-15 03:34:21
i thought i did that but i guess not. i guess if it's not above it will work occasionally...but odd it worked EVERY time on my local machine
Tony
2010-06-15 03:48:21
Logically, scripts are executed in order, and $ is not defined when that inline script runs, so it *should* throw an error. It did work for me, too.
Alex JL
2010-06-15 04:06:12