Ajax post调用似乎有效,仍然抛出错误?

Ajax post调用似乎有效,仍然抛出错误?,ajax,asp.net-web-api,Ajax,Asp.net Web Api,虽然代码按预期工作,但它抛出 “尝试联系服务器时出错:200 parsererror SyntaxError:JSON输入意外结束” 永远不会调用success分支,但数据会到达api 我应该关注并解决它,否则它可能不会在哪里引起问题?谢谢你的帮助 <script> $(document).ready(function () { $("#Save").click(function () {

虽然代码按预期工作,但它抛出

“尝试联系服务器时出错:200 parsererror SyntaxError:JSON输入意外结束”

永远不会调用success分支,但数据会到达api

我应该关注并解决它,否则它可能不会在哪里引起问题?谢谢你的帮助

       <script>
        $(document).ready(function () {
            $("#Save").click(function () {
                var data2send = JSON.stringify("test");
                $.ajax({
                    url: 'https://localhost:44348/api/products/PostProduct',
                    type: 'POST',
                    data: data2send,
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (data2send) {
                        console.log(data2send);
                    },
                    error: function (jQXHR, textStatus, errorThrown) {
                        console.log("An error occurred whilst trying to contact the server: " + jQXHR.status + " " + textStatus + " " + errorThrown);
                        console.log(data2send);
                    }
                });
            });
        });
    </script>
    [HttpPost]
    [Route("PostProduct")]
    public void Post([FromBody] string obj)
    {
        Product.prod.Add(new Product() { ProductId = 12, ProductName = obj, Price = 12 });
    }