No description, website, or topics provided.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

General Assembly Logo

jQuery AJAX Delete Element



By the end of this, developers should be able to:

  • Make HTTP requests using curl and AJAX to:
    • Delete a specific resource.
  • Use response data in future requests.


  1. Fork and clone this repository.
  2. Create a new branch, training, for your work.
  3. Checkout to the training branch.
  4. Install dependencies with npm install.

DELETE /books/:id

Delete a book from the API

Review: GET Single Book

First let's ensure we can get a book with a specific id.

Enter into the chrome address bar to retreive a single book with id=1

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:

  1. Add a new form with text input for a book id to the form in index.html.
  2. Add a Delete button to the form.
  3. Add an event listener on the form's submit action within assets/scripts/index.js.
  4. Retrieve the value of the id, if any, in the submit handler.
  5. Branch on that value in the submit handler.
  6. Add a delete single book method to assets/scripts/books/api.js.
  7. Add a delete single book success and fail handler to assets/scripts/books/ui.js.
  8. Invoke the delete single book method from the submit handler passing the success and fail callbacks.


  1. All content is licensed under a CC­BY­NC­SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact