From the course: Ajax with PHP: Add Dynamic Content to Websites

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Requests

Requests

From the course: Ajax with PHP: Add Dynamic Content to Websites

Start my 1-month free trial

Requests

- [Narrator] In this chapter, we're going to learn to work with the client side of Ajax. That is the JavaScript, which is loaded into the browser, and which sends requests to the web server and then handles the responses that come back from the web server. In the next chapter, we'll look at the server side to see how PHP can respond to those Ajax requests. Let's start by learning how to generate a new Ajax request. As we talked about in the introduction, Ajax requests are enabled by this XMLHttpRequest object. It's a bit of JavaScript code, actually a JavaScript class that we can use for making our Ajax requests. And there are a few functions that we need to know about to work with it. There's new, there's open, and there's send. Let's take a look at a code example so we can learn how we use new, open, and send with that XMLHttpRequest object. Again, this is JavaScript code that we're going to be writing. To begin with, I'm going to create a new variable called xhr and to that…

Contents