samedi 9 février 2019

How to define Laravel action function in ajax url?

I'm facing problem with laravel ajax i want to define url using laravel action() or route('page.destory') function with id . Ajax code is here

$(".delete").click(function(){
var id = $(this).data("id");
var token = $("meta[name='csrf-token']").attr("content");

$.ajax(
{
    url: "+id",
    method: 'DELETE',
    data: {
        "id": id,
        "_token": token,
    },
    success: function (data){
        alert(data);
    }
});

});

Laravel give me error Missing required parameters for [Route: page.destroy]

in web.php Route::resource('page','PageController);

How can i pass id with that action of destroy. url should be look like http://example.com/admin/page/1. but i do not want to write url manually.Many Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire