0

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

mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • 1
    Your code above does not give this error. You have an error elsewhere. Also you only need to delegate if the form is added after the page loads – mplungjan Nov 13 '19 at 13:59
  • 1
    And what is the server response for this request? – Styx Nov 13 '19 at 14:09

0 Answers0