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

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Responses

Responses

- [Instructor] In the previous movie, we learned how to send an Ajax request. In this movie, we're going to learn how to receive and handle the response that comes back from that request. The first thing you need to know about the Ajax responses, is that they can either be text, or they can be XML, and we access them in different ways. We're going to use a function called responseText when we want to work with the text, and responseXML when we want to work with XML. In general, the text is going to be more flexible, because the text is just a string of characters. What we get back could be a couple of words, or a sentence or a paragraph, or it could be HTML, or it could be JSON, it could be images, it really doesn't matter, it could be any string of characters that gets sent back, whereas XML is only going to be XML. You'll remember though, that the x in Ajax actually stands for XML, so it is a central part of the way that Ajax works. Let's take a look at some code as an example. So…

Contents