jQuery AJAX Delete Element
By the end of this, developers should be able to:
- Make HTTP requests using
curland AJAX to:
- Delete a specific resource.
- Use response data in future requests.
- Fork and clone this repository.
- Create a new branch,
training, for your work.
- Checkout to the
- Install dependencies with
Delete a book from the API
Review: GET Single Book
First let's ensure we can get a book with a specific id.
https://wdi-library-api.herokuapp.com/books/1 into the chrome address bar to retreive a single book with
We can also use curl to retrieve one book at a time.
Demo: Delete Single Book using Curl
We'll use curl with the DELETE http verb to signify to our API that we want to delete the book
Why can't we delete a book using the browser address bar?
Code Along: Write Curl Script
Let's write that curl command into a script.
Lab: AJAX Delete Single Book
Again, take a stepped approach:
- Add a new form with text input for a book id to the form in
- Add a Delete button to the form.
- Add an event listener on the form's
- Retrieve the value of the id, if any, in the submit handler.
- Branch on that value in the submit handler.
- Add a delete single book method to
- Add a delete single book success and fail handler to
- Invoke the delete single book method from the submit handler passing the success and fail callbacks.
- All content is licensed under a CCBYNCSA 4.0 license.
- All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact firstname.lastname@example.org.