I am new to laravel and I want to make an ajax call to a function written in controller. I have done the following but not working.
In View :
$.ajax({
type: "POST",
url: 'OrderData', // Not sure what to add as URL here
data: { id: 7 }
}).done(function( msg ) {
alert( msg );
});
My Controller which is located inside app/controllers/DashBoardController.php and inside DashBoardController.php I have
class DashBoardController extends BaseController {
public function DashView(){
return View::make('dashboard');
}
public function OrderData(){ // This is the function which I want to call from ajax
return "I am in";
}
}
My Question is how can I make an ajax call from view on page load to a function inside my DashBoardController.php ?? Thanks.