首页 > 解决方案 > ajax 调用的输入意外结束

问题描述

这是我在 Laravel 项目中的代码

$('.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)
    }
  });
})

这是我的错误- Uncaught SyntaxError: Unexpected end of input

标签: jquerylaravel

解决方案


推荐阅读