In my Laravel Projects, I want to pass data from blade to my controller using Ajax.
But I am getting error
404 | Not Found
ajax
var pi_id = $(this).attr('href');
$.ajax({
url: "{{ url('purchase-invoice-detail') }}",
type: "get",
data: {
'id': pi_id
},
success: function(response){ // What to do if we succeed
alert('ok');
},
error: function(response){
alert('Error'+response);
}
});
route
Route::get('purchase-invoice-detail/{id}', 'PurchaseController@purchase_invoice_detail')->middleware('auth');
controller
public function purchase_invoice_detail($id)
{
return 1;
}
Can't find the problem.
Anybody Help Please ?
请尝试此代码
"{{ url('purchase-invoice-detail') }}" + '/' + pi_id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.