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.

Format suggestions with JSON

Format suggestions with JSON

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

Start my 1-month free trial

Format suggestions with JSON

- [Instructor] In the previous movie, we were able to search through our data set, find the suggestions that we wanted to return, and send them back to the Ajax request as json data. Now, we need to take that json data, we need to properly format it as html and put it on the page so the user can see it. Let's start by going in to public.js, and I'm going to start out by taking out the place where put in the fake json before. We don't need that any more. We actually have real json now. So that real json result that comes back in response text will now be parsed into proper json, and it will be passed to the showSuggestions function. Scroll up here, showSuggestions takes json as an argument. You can see that we already have some style information here that will make it that suggestions appear. What we need to do now is take that json and convert it into html. Let's just review what that needs to look like. Let's look at the header.php. Here's our suggestions that we created earlier. So,…

Contents