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.

Load remote text

Load remote text

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

Start my 1-month free trial

Load remote text

- [Instructor] Now that we know how to handle Ajax requests, server responses, and also how to inspect the current state and trigger code whenever that state changes, we're ready to put it all together in our first example. We'll create a simple HTML page, which will load new next from another file asynchronously by using Ajax. I'm going to start out with a bit of code in a couple separate files. You can see that I've got them in a directory here called ajax_text and the first file is index.html and the 2nd is new_content.txt. These are also included in the exercise files if you have access to those. They're pretty simple. Let's open them up in the Atom text editor to take a look. So when I drag the folder into Atom, it opens it up in project view. Let's look at new_content.txt first. It just a very simple text file with just a single sentence in it. This is the new content which has been loaded by Ajax. That's the content that I'm going to be loading in. So you can use any text you…

Contents