O'Reilly logo

Lift Application Development Cookbook by Gilberto T. Garcia Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Deleting data using the REST service

Our application to manage clients using a REST API is almost ready. The last thing that we need to learn is how to destroy data using our API.

Getting ready

As you can imagine, you have only two options. Either duplicate the project from the last section or keep evolving the same project.

  1. In the index.html file, modify the createLine function by changing the line with the Delete column from:
    '   <td>Delete</td>' +

    to:

                        '   <td><a href="#" data-id="' + data.id + '" onclick="deleteClient(this)">Delete</a></td>' +
  2. Create the deleteClient function, which will make the delete call to the server:
     var deleteClient = function(element) { $.ajax({ async: false, type: "delete", url: "/api/clients/" + $(element).data("id"), contentType: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required