Laravel 8.x Delete Record Using Ajax Request Example

Today i will show you how to delete data using ajax request in Laravel 8. you have to simply follow few things to make done delete record from database using ajax request.

In this tutorial i will simply delete a column record using ajax request. You will learn from this tutorial about Laravel destroy using ajax request.If you don't know how to do it, just follow below things.

You know that when we send ajax request to server to delete data, then page won't refresh but our data will be deleted. How cool, isn't it? We will use POST request to delete data from database using ajax request.

we will create delete route with controller method(we will write delete row code using database model) and write jquery ajax code with delete post request. we also pass csrf token in jquery ajax request, otherwise it will return error like delete method not allowed.



So let's start delete row using ajax in laravel tutorial. 


Read also : Form Validation with File Upload in Laravel 6


Create Route: routes/web.php

Route::delete('/addcompany/{id}', 'CompanyController@destroy')->name('company.destroy');


Paste this below code in your controller to delete data in laravel using ajax request.


public function destroy($id){
      $company = Company::find($id);
      return response()->json([
        'message' => 'Data deleted successfully!'



Paste this below code in your blade view file to delete data in laravel using ajax request.



Read also : Ajax Login Form Using jQuery, PHP And MySQLi



$(document).ready(function () {


    if(!confirm("Do you really want to do this?")) {
       return false;

    var id = $(this).data("id");
    // var id = $(this).attr('data-id');
    var token = $("meta[name='csrf-token']").attr("content");
    var url =;

          url: url.href, //or you can use url: "company/"+id,
          type: 'DELETE',
          data: {
            _token: token,
                id: id
        success: function (response){


              'Company deleted successfully!',
      return false;



Hope it can help you.


#ajax-request #laravel #ajax #laravel-6 #delete