在Laravel中删除带有JSON的条目

I have a dynamically generated table that also have this button:

<button class="btn btn-danger btn-xs btn-delete delete-task" 
value="{{$contact->id}}">delete</button>

At the end of the code I have this:

<meta name="_token" content="{!! csrf_token() !!}" />

The button triggers this:

$(document).ready(function(){

$('.delete-task').click(function(){
    var contact_id = $(this).val();

    $.ajax({
        type: "DELETE",
        url: adressbook_edit + '/' + contact_id,
        success: function (data) {
            console.log(data);
            $("#contact" + contact_id).remove();
        },
        error: function (data) {
            console.log('Error:', data);
        }
    });
});
}

Which is supposed to lead to my routes like this:

Route::delete('/adressbook_edit/{$contact_id?}',function($contact_id){
    $contact = addressbook::destroy($contact_id);
    return Response::json($contact);
});

I am expecting to delete the entry in the database, however I get a 404 error. The direction is apparently correct. Here is the error I get:

DELETE http://myip/adressbook_edit/2 404 (Not Found) send @ app.js:26 ajax @ app.js:25 (anonymous) @ adressbook.js:79 dispatch @ app.js:25 g.handle @ app.js:25 adressbook.js:87

Error: Object {readyState: 4, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function…}

Adressbook.js is where the aforementioned ajax function is called.

Try to change your ajax url to this:

 url: '/adressbook_edit/' + contact_id

And also change your route to this:

Route::delete('/adressbook_edit/{contact_id}',function($contact_id){
    $contact = addressbook::destroy($contact_id);
    return Response::json($contact);
});