This is my code in Laravel project
$('.add').submit(function(e) {
e.preventDefault();
let form = $(this).closest('form'),
fd = form.serializeArray(),
postId = $('input[name=post_id]').val();
$.ajax({
headers: {
'X-CSRF-TOKEN': $('.csrf-token').val()
},
type: "POST",
url: "posts/" + postId + "/comment",
dataType: "JSON",
data: fd,
success: function(res) {
console.log(res)
},
error: function(error) {
console.log(res)
}
});
})
And this is my error-Uncaught SyntaxError: Unexpected end of input