So far I have a User view that contains a typehead input box and a button.
I can manage to get the id of the selected user and display it when clicking on the button:
$('#load').bind('click', function(e)
{
alert(selected);
});
Now I want to retrieve the data for the selected user from the database and display it in the User view. Here is my jQuery, route and controller:
var details = '<?php echo URL::to('details'); ?>';
$.getJSON(
details,
function(data)
{
$('#details').html(data);
}
);
Route::get('details', 'HomeController@Details');
public function Details()
{
$data = array('name' => 'Ste');
return View::make('user')->nest('details', $data);
}
I've read multiple articles of AJAX in Laravel but am no closer to getting this working.
Does anyone know of a good tutorial for doing this or am I doing something obviously wrong?