This forum is now read-only. Please use our new forums! Go to forums
banner
Close banner
Why won't my "Drag Racing" codeacademy code work locally?
I have successfully completed “Drag Racing” exercise @codeacademy, but when I copied all the same code locally, the car appeared, but I couldn’t drag it. Please advise!
Answer 5490e80195e378bc1f000f0e
0 votes
You need to link out to the jQuery core library. There are several CDN’s where it can be linked from. The following uses two of them, one for the core, one for UI
<script src="http://code.jquery.com/jquery-1.11.1.min.js"><script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
Load these scripts (in this order) before your custom script so it is present when your script fires. Style sheets should be loaded before any scripts.
For running locally, do not use schemeless protocol ("//ajax. ..."
) or it will resolve to your computer’s file://
protocol, not http://
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
5 comments
I knew it was about the scripts linking, but never realized the order mattered. Thanks!
first == core and second == UI ?? I want to put a comment.
Script loads and parses in the order that the files are listed in the document, starting with the HEAD and then the BODY. Non-deferred script fires as soon as it is parsed. I’m not sure that jQuery is defined in the UI, so it follows that library depends upon the jQuery core to define $ (jQuery). Likewise, if our own script makes calls to jQuery, it won’t exist if not already loaded. In general terms, order is implied when there are dependencies.
so, what do I put in? the file:// or the http://! Thanks anyway!
http:// so it resolves to the web.