简体   繁体   English

错误-变得更大的JSON文件时出现意外令牌

[英]ERROR - unexpected token when getting bigger JSON file

I have a textbox that takes user input, sends it to WS, where it searches for anything matching said data and returns all that it finds as JSON. 我有一个文本框,用于接收用户输入,将其发送到WS,在其中搜索与所述数据匹配的所有内容,并将所有找到的内容作为JSON返回。 Then I take said json and fill a table. 然后我说json并填写表格。 If the user input is quite specific I get the data and table is created with no problems, if the user input is not specific I get quite a lot of data in my JSON, BUT I also get ERROR - unexpected token, and the table stays empty. 如果用户输入是特定的,我得到的数据和表都没有问题,如果用户输入不是特定的,我在JSON中得到了很多数据,但是我也得到了错误-意外的令牌,并且表保持不变空的。

My js 我的js

$('#btnFilter').click(function () {
var filter = $('#txtFilter').val();
var sqlCall = ""
    callJsonWs("EXECUTE procedure", "loadPageFilter");
});


function loadPageFilter(dataJSON) {
var data
try {
    data = JSON.parse(dataJSON)
}
catch (err) {
    alert("ERROR - " + err.message)
}
document.getElementById("tableFilterPopup").innerHTML = ''
$.each(data.filter, function (index, value) {
    document.getElementById("tableFilterPopup").innerHTML += '<tr onclick="newLocation(\'' + value.pageView + '\')">'

                             + '<td>' + value.jobCode + '</td>'
                             + '<td>' + value.jobCustomerName + '</td>'
                             + '<td>' + value.jobPhoneNumber + '</td>'
                             + '<td>' + value.jobModel + '</td>'

                         + '</tr>';
})
}

正如Gregg Duncan提到的那样,问题在于无效的JSON格式中断了,因此我得到的是不完整的JSON字符串。

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

相关问题 在 position 0 的 json 中发送表单时出现错误 - Getting error when sending form -unexpected token s in json at position 0 调用外部文件时,json中的“意外令牌” - 'Unexpected Token' in json when calling an external file 从asyncStorage获取时的JSON.parse(object)引发错误:位置1的JSON中的意外令牌o - JSON.parse(object) when getting from asyncStorage throws error: Unexpected token o in JSON at position 1 获取错误 - &gt;意外的令牌} - Getting error -> Unexpected token } 收到“意外令牌错误” - Getting an “Unexpected Token Error” 为什么我在 JSON 文件中收到错误消息“SyntaxError: unexpected token: ':'”? - Why am I getting a error saying “SyntaxError: unexpected token: ':'” in a JSON file? 获取&#39;未捕获的SyntaxError:意外的令牌o <unknown file> :使用JSON.parse时为1&#39; - Getting 'Uncaught SyntaxError: Unexpected token o in <unknown file>:1' when using JSON.parse 尝试在简单对象上执行JSON.parse时出现“意外令牌”错误 - I am getting an “Unexpected token” error when trying to do JSON.parse on a simple object 在 REST 响应上使用 JSON.parse(...) 时出现 Unexpected Token U 错误 - getting Unexpected Token U error when using JSON.parse(…) on REST Response 为什么我在 JSON 中的位置 0 处收到 Unexpected token &lt; 的错误 - Why am I getting an error of Unexpected token < in JSON at position 0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM