click on a table row and redirect to view using jquery and laravel 5 -
there table rendering list of persons columns this:
<table> <tr> <th>first name</th> <th>last name</th> <th>age</th> </tr> <tr class="person"> <td class="fname">john</td> <td class="lname">doe</td> <td class="age">30</td> </tr> </table>
and more other. when user clicks on row, new view more data selected preson should loaded, using jquery. like:
//main.js:
$(document).ready(function(){ $("#person").click(function(){ var lname = $(this).children("lname").val(); $.ajax({ url:'profile', type: 'get', data: 'lname' : lname, datatype: 'json', success: function(result){ } }); } });
//routes.php:
route::get('profile', [ 'as' => 'profile', 'uses' => 'pagescontroller@profile' ]);
//controller.php
public function profile() { return view('pages.profile'); }
what correct way that?
$(".person").click(function(){ var lname = $(this).children("lname").val(); $.ajax({ url:'profile', type: 'get', data: 'lname' : lname, datatype: 'json', success: function(result){ } }); }
will hope
Comments
Post a Comment