I've got a problem with sending data from javascript to my controller. There is my Ajax:
var point = JSON.stringify(points);
function onBtnClick() {
$.ajaxSetup({
header:{
'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content')
}
});
$.post('http://localhost/updateC', {
data: point,
dataType: 'json',
contentType:'application/json',
})
.done(function() {
alert('success');
})
.fail(function() {
alert("error");
});
}
Routes:
Route::get('/home', 'HomeController@index')->name('home');
Route::resource('/races','RacesController');
Route::post('updateC', 'RacesController@Points');
And there is my RacesController:
public function Points(Request $request) {
$test = $request->input('data');
return "$test";
}
And the error is saying that has been blocked by CORS-polices.