laravel pass data to controller using ajax code example
Example: laravel ajax post data to controller
$.ajax({
url: "/route/to",
type: 'POST',
beforeSend: function (request) {
return request.setRequestHeader('X-CSRF-Token', $("meta[name='csrf-token']").attr('content'));
},
success: data => {
console.log(data);
}
});