简体   繁体   中英

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. Then I take said json and fill a table. 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.

My 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字符串。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM