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.
As you can imagine, you have only two options. Either duplicate the project from the last section or keep evolving the same project.
In the
index.html
file, modify thecreateLine
function by changing the line with theDelete
column from:' <td>Delete</td>' +
to:
' <td><a href="#" data-id="' + data.id + '" onclick="deleteClient(this)">Delete</a></td>' +
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: "application/json" }).done(function (data) { $(element).parents...