简体   繁体   English

为什么收到“ Uncaught SyntaxError:JSON输入意外结束”?

[英]Why am I getting 'Uncaught SyntaxError: Unexpected end of JSON input'?

<script type="text/javascript">
      setInterval(function() {

        $.ajax({
          type: "POST",
          url: "http://localhost/alaris/admin/product_notification",
          data: JSON.stringify({ product:"product"}),
          success: function(res) {
            $("#product_notify").html(res);
            //alert(res);
          }   
        });
     }, 5000);
    </script>

When I'm running the above code it displays following error message in the console 当我运行上面的代码时,它将在控制台中显示以下错误消息

Uncaught SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Function.n.parseJSON (jQuery-2.1.4.min.js:4)
    at Object.success (custom.js:85)
    at j (jQuery-2.1.4.min.js:2)
    at Object.fireWith [as resolveWith] (jQuery-2.1.4.min.js:2)
    at x (jQuery-2.1.4.min.js:4)
    at XMLHttpRequest.<anonymous> (jQuery-2.1.4.min.js:4)
n.parseJSON @ jQuery-2.1.4.min.js:4
success @ custom.js:85
j @ jQuery-2.1.4.min.js:2
fireWith @ jQuery-2.1.4.min.js:2
x @ jQuery-2.1.4.min.js:4
(anonymous) @ jQuery-2.1.4.min.js:4

Can anyone would find what the error is? 谁能找到错误所在?

如果product是对象:

JSON.stringify({ "product" : product })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我遇到了这样的问题:未捕获(承诺)SyntaxError:JSON 输入的意外结束 - I am getting such Kind Of Problem : Uncaught (in promise) SyntaxError: Unexpected end of JSON input 为什么我收到错误</script> ? 错误是 (Uncaught SyntaxError: Unexpected end of input) - Why am I receiving an error on </script> ? the error is (Uncaught SyntaxError: Unexpected end of input) 获取 Uncaught SyntaxError: Unexpected end of input - getting Uncaught SyntaxError: Unexpected end of input Javascript:未捕获的SyntaxError:JSON输入意外结束 - Javascript: Uncaught SyntaxError: Unexpected end of JSON input 未捕获的SyntaxError:JSON输入意外结束[} - Uncaught SyntaxError: Unexpected end of JSON input [} 错误:未捕获的语法错误:JSON 输入意外结束 - Error: Uncaught SyntaxError: Unexpected end of JSON input 未捕获(承诺中)SyntaxError:JSON 输入意外结束 - Uncaught (in promise) SyntaxError: Unexpected end of JSON input Uncaught SyntaxError:JSON输入意外结束 - Uncaught SyntaxError: Unexpected end of JSON input 未捕获的语法错误:JSON 输入 Codeigniter 意外结束 - Uncaught SyntaxError: Unexpected end of JSON input Codeigniter 为什么我会收到“Uncaught SyntaxError: Unexpected reserved word”? - Why am I getting "Uncaught SyntaxError: Unexpected reserved word"?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM