jeudi 28 juin 2018

setting up a jQuery load using a route and data parameter in Laravel 5

I have a route in my web.php file:

Route::get('noBodyDetail/{id}','VehiclesController@noBodyDetail')->name('noBodyDetail');

and in a datatables I am trying to establish a link using a javascript call:

<a href="#" onclick="showDetail()">@fa('eye')</a>

All OK so far.

My problem is calling the named route in a javascript function.

I have tried

 `function showDetail(id)
 {

   var url = "/" + id;
   $( "#detail" ).empty();
   $( "#detail" ).load( url );
 }`

But I am getting a missing parameter error

Missing required parameters for [Route: noBodyDetail] [URI: admin/noBodyDetail/{id}].

Can someone point out to me how to call a named route and passing a parameter in a javascript function?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire