Now that there is a working favorite button, learn how to duplicate the process and create an unfavorite button. Clicking on an unfavorite button will send an asynchronous Ajax request to a PHP page, which will remove the post from the list of favorites. Then Ajax will remove the red heart from the corner of the blog post.
- [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 favorite hover will also need…
- What is Ajax?
- Creating Ajax requests and responses
- Monitoring Ajax request state and events
- Responding to Ajax requests with HTML and JSON
- Building Ajax buttons
- Submitting forms with Ajax
- Implementing infinite scrolling
- Adding autosuggestions to text fields
Skill Level Intermediate
1. Ajax Defined
What is Ajax?5m 34s
2. Ajax Client
3. PHP Server
4. Ajax Button
5. Ajax Form Submission
6. Infinite Scrolling
7. Search Autosuggest
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.