Код: Выделить всё
function getMessage() {
$.ajax({
//var data = {"_token": $('#token').val()},
type:'POST',
url:'/getMsg',
headers: {'XSRF-TOKEN': $('meta[name="_token"]').attr('content')},
success:function(data) {
$("#msg").html(data.msg);
}
});
}
Код: Выделить всё
Route::post('/getMsg','CustomerSearchController@doAjaxTest');
Код: Выделить всё
public function doAjaxTest(){
$msg = "Message over ajax This test is Successful[/b].";[b] return response()->json(array('msg'=> $msg), 200);
}
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/62673918/message-csrf-token-mismatch-exception-symfony-component-httpkernel-except[/url]