I sent an Ajax call which showed an error message:
500 Internal Server Error
I have gone through some posts over Stackoverflow and understand that I have to passed csrf token. Thus, I have pasted this following code within the head section (just before the closing of the head tag).
<meta name="csrf_token" content="">
Also, here is the Ajax codes that I called;
$.ajax({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
},
url: "adminUser/exportselected/1",
type:'POST',
data: {selected:selected, selectedField:selectedField},
success: function(data) {
window.location = data.path;
if($.isEmptyObject(data.error)){
//alert(data);
}else{
//alert(data.error);
}
}
});
As you can see from the above, I have also passed the token with the headers. Anything else I need to do?
My route (web.php) is as under:
Route::post('adminUser/exportselected/{page?}', 'Administrator\AdminUserController@exportSelected');
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2wRyDC8
via IFTTT
Aucun commentaire:
Enregistrer un commentaire