Start learning with our library of video tutorials taught by experts. Get started

JavaScript and AJAX

Understanding and installing jQuery


From:

JavaScript and AJAX

with Ray Villalobos

Video: Understanding and installing jQuery

jQuery is a framework that fixes compatibility issues that happen with JavaScript in older browsers. The library also gives you a lot of additional tools for working with the DOM. One of my favorite features of the framework is how easy it makes it to work with AJAX. So let's go ahead and take a look at some of the options you have for installing jQuery. So there's two ways you can include jQuery into your projects. You can download a copy or use it from a CDN. A CDN is a content delivery network. You can see links to those if you click on the Download tab right here and then look over here to the left.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
JavaScript and AJAX
1h 12m Intermediate Jan 18, 2013

Viewers: in countries Watching now:

The ability to read data and communicate information asynchronously is fundamental to modern web applications. In this course, author Ray Villalobos takes a look at integrating AJAX (Asynchronous JavaScript and XML) with JavaScript and jQuery—a combination that makes it easy to work with dynamic data and reduces the number of requests to the server. The course first explains what AJAX is, and shows how to load and reload pages with pure JavaScript, update the DOM, and read and parse data in the XML and JSON formats. Next, learn how to read and write information between the server and the client with AJAX methods in jQuery, and build a dynamic search application that updates search results as you type.

Topics include:
  • What is AJAX?
  • Making requests asynchronous
  • Updating the DOM with getElementById
  • Reading JSON files
  • Working with jQuery and AJAX
  • Sending and searching JSON data
  • Incorporating CSS transitions
Subjects:
Developer Web Programming Languages Web Development
Software:
Ajax JavaScript
Author:
Ray Villalobos

Understanding and installing jQuery

jQuery is a framework that fixes compatibility issues that happen with JavaScript in older browsers. The library also gives you a lot of additional tools for working with the DOM. One of my favorite features of the framework is how easy it makes it to work with AJAX. So let's go ahead and take a look at some of the options you have for installing jQuery. So there's two ways you can include jQuery into your projects. You can download a copy or use it from a CDN. A CDN is a content delivery network. You can see links to those if you click on the Download tab right here and then look over here to the left.

Those are links to the most popular CDN libraries that have jQuery. You can also try cdnjs.com; that has copies of a lot of libraries, including jQuery. So the advantage of using a CDN is that if a browser has loaded your library from a CDN when you visited some other website, it may already be cached in your browser when it comes to your site, so your page will load a lot faster. The disadvantage is that CDNs will only work while you have a live connection to the Internet. If you're working with a local copy or maybe flying around on an airplane or coding where your connection is spotty, then the CDN is not going to load at all and none of your JavaScript will work.

So you load them both into your code in pretty much the same way. So let's go ahead and go to the front of the jQuery website and click on this Download link. Now, before you do that, see that there's two options here. You have the option of downloading a Production version or a Development version. Now, the Development version has a copy of all the code with comments that's super easy to read, but it's obviously a lot bigger. Whereas the Production is minified and Gzipped, which means that it's compressed, it has no comments, a lot of the variable names have been changed so that they're smaller, and it's really pretty impossible to read.

You should use the Development version if you're going to be editing something about the jQuery JavaScript code; otherwise, just use the Production version, and that's what I'm going to do. So I'll click on Download jQuery. Sometimes you see this kind of code right here, which is essentially the JavaScript code for jQuery. I told you the Production version was hard to read, and I wasn't kidding. Now, to save this I'm going to go to the File menu-- I'm using Safari right now--and I'm going to select Save As. And here I'm just going to rename this jquery.js and I'll just save it on the Desktop.

I want to make sure that from this Format menu, I choose Page Source. Make sure it's not in Web Archive. So I'll select that, hit Save, and now that saves it into our desktop, so I'm going to switch there. And what I need to do now is copy this into my server, so I'll copy that just by dragging it. I'm using Transmit as my FTP program, so there it is. It's already on my server. And now what I want to do is select the files that I need and open them up in my editor. So I've got all these files opened up in my editor.

There's the jquery.js library. I really don't need to see it, so I'm just going to close it up. What I need to do to insert it is go to my index.html file and then load it up just like I would any other script. I want to make sure that I load it up before my script.js, because that's where I'm going to be putting my regular JavaScript and I want to make sure that the library is there before my other scripts load. So I'll do a script tag, and as the source I'll just type in jquery.js. I don't need this part. Now, the only difference between this and loading it from a CDN is that if you were to load this from a content delivery network, you'd want to get the URL of the library and just copy that from here and paste it into your script tag.

But I'm not going to do that because I'm just using a local copy. So save it and now jQuery will load into my application, and it's ready for me to use. Loading up jQuery is normally done using one of the CDNs when you're in production, but keep in mind that if you're going to be offline and developing, then downloading a copy is a super-smart idea. One more thing: you should always load jQuery before your regular JS file. That way all the power of the framework is going to be available when you write your scripts.

There are currently no FAQs about JavaScript and AJAX.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed JavaScript and AJAX.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked