我正在尝试使用 JSON 解析网站。我在 JSON.parse 行不断收到错误消息。这是我一直在该行遇到的错误:
Exception is about to be caught by JavaScript library code at line 31, column 21 in ms-appx://37099737-8761-481d-b1e3-38412d272486/pages/search1/search1.js
0x800a03f6 - JavaScript runtime error: Invalid character
If there is a handler for this exception, the program may be safely continued.
这是我的代码:
loadWebsite: function (totalSearch) {
WinJS.xhr({url: totalSearch}).then(
function (response) {
var json = JSON.parse(response.responseText); //this line here
var list = new WinJS.Binding.List(json.results);
gridView1.winControl.itemDataSource = list.dataSource;
},
function (error){ console.log(error); },
function (progress) { }
);
return;
}