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.

Create an unfavorite button

Create an unfavorite button

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

Start my 1-month free trial

Create an unfavorite button

- [Instructor] We have a working favorite button using Ajax. The last step is for us to create an unfavorite button so that we can also undo our action. The process is almost identical. I'm going to walk you through it, but if you think you have a good grasp on the previous code, then I would encourage you to pause the movie and attempt it on your own first. Then you can watch me if you get stuck. The first thing we're going to do is we're going to switch over to our index.php page, and we want to duplicate the button that we had, so here's our favorite button. I'm going to just copy that. I'm going to put another button right below it. It's going to be called unfavorite button. Unfavorite, and I'm going to copy that button, and let's put it down here below these two as well, and then we want to make sure that the CSS applies as well. You see that I have button.favorite-button up here. I'm going to copy that, and I'm going to make it also apply to the unfavorite button. Button…

Contents