Now that we have jQuery, let's jump right into using it to improve our site a little bit. There are a lot of different ways in which you can write the jQuery and JavaScript code, but we're going to stick to the absolute basics in this book and try to keep it simple.
One of the things you might have noticed early in the last chapter is that when we coded the deletion of posts from the user's profile, we actually used the GET HTTP
method instead of the DELETE
method. This is because it's difficult to trigger a DELETE
route without using JavaScript. So, in the following section, we're going to improve the deletion process in order for it to work as follows:
1. A user clicks on Delete on a post.
2. A
DELETE AJAX
request is made from jQuery to our application.3. Our application will delete the post document and report back to jQuery that everything went as expected.
4. The post will fade from the view without...