javascript - 语法错误 : Unexpected end of input

标签 javascript jquery json

我收到 SyntaxError: Unexpected end of input。代码看起来不错,我错过了什么?

function SaveGridster(jsonState) {
        console.log('SaveGridster'); // I CAN SEE THIS IN CONSOLE
        var msttou = {
            "srno": "1",
            "module": "ABT Meter Details",
            "userid": "SYS",
            "jsondata": "jsonState"
        };


        $.ajax({
            type: "POST",
            contentType: "application/json;charset=utf-8",
            url: BaseAddress + "InstanceDataAPI",
            dataType: "json",
            data: JSON.stringify(msttou),
            success: function (response) {
                console.log('success');
            },
            error: function (xhr, status, error) {
                console.log(error);
                alert(xhr.responseText);
            }
        });
    }

控制台:

SyntaxError: Unexpected end of input
    at Object.parse (native)
    at jQuery.extend.parseJSON (http://localhost:2402/Scripts/jquery-1.10.2.js:564:23)
    at ajaxConvert (http://localhost:2402/Scripts/jquery-1.10.2.js:8443:19)
    at done (http://localhost:2402/Scripts/jquery-1.10.2.js:8199:15)
    at XMLHttpRequest.callback (http://localhost:2402/Scripts/jquery-1.10.2.js:8792:8)

最佳答案

错误似乎出在您的函数获得的 AJAX 响应中。 SyntaxError 由 JSON 解析器发出。将数据类型转换为“文本”以禁用 JSON 解析。

关于javascript - 语法错误 : Unexpected end of input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36617717/

相关文章:

javascript - Intro.js - 有什么方法可以防止点击外部时关闭游览?

javascript - 正确评估字符串值并在 JavaScript 中格式化它

javascript - jqueryparent().find(input).val();单击时访问一个表格单元格中的两个输入字段

javascript - Vue.js:将 router-link-active 添加到为 root 加载的 vue-router 组件

jquery - 滚动时为图像设置动画

javascript - 如何获得将数据发送到聊天框的提示框?

javascript - 如何访问 Dynatable AJAX 调用请求的 JSON 中的附加数据

json - 带有 Handlebars 模板的嵌套 {{each}} 循环

JavaScript JSON 响应 - 格式化日期和时间

javascript - ZK 自定义日历弹出窗口