I'm trying to make a POST to
http://localhost:8888/test
JS
$('.saveBTN').click(function (event) {
$( "form#editForm" ).on( "submit", function( event ) {
event.preventDefault();
var inputs = {};
$("#editForm :input").each(function() {
inputs[$(this).attr("name")] = $(this).val();
});
var $inputs = JSON.stringify(inputs);
$.ajax({
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
url: '/test',
type: 'POST',
dataType: 'json',
data: $inputs,
success: function (data, textStatus, xhr) {
console.log(data);
},
error: function (xhr, textStatus, errorThrown) {
console.log('PUT error.');
}
});
});
I keep getting
500 Internal Server Error
I've tried added
<meta name="csrf-token" value="{{ csrf_token() }}">
and this on my Ajax
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
Any hints on this will be much appreciated !