From the course: Ajax with PHP: Add Dynamic Content to Websites
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Using jQuery
From the course: Ajax with PHP: Add Dynamic Content to Websites
Using jQuery
- [Instructor] jQuery is a very popular JavaScript framework. So far, we've been writing our AJAX requests and response handling in pure JavaScript. Many developers use jQuery to write their AJAX code too. I'm sure that there are many watching this course who are already using jQuery and plan to use it to write their AJAX code. In this movie, I want us to take a quick detour to see how you could write the same code in jQuery. First, here's the pure JavaScript version that we've been working with. We create a new XML http request object, then we call open, set it up for where it should it go, what kind of request it should be and where the script is located. Then we set up our callback function for on ready state change. Every time the state changes, we're going to have the opportunity to check what the state is, to check what the status is, and handle it appropriately. And finally, we call send to actually trigger the request. Now here's the jQuery version. Dollar sign dot ajax, and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.