我需要一些有关此错误的帮助:
未捕获的 SyntaxError:在 Object.success (dashboard.js:22) at fire (jquery-3.3.1.js:3268) at Object.fireWith [as resolveWith] (jquery-3.3) 处的 JSON.parse () 处的 JSON 输入意外结束.1.js:3398) 在完成 (jquery-3.3.1.js:9305) 在 XMLHttpRequest。(jquery-3.3.1.js:9548)
我尝试使用导致该错误的JSON.parse()将字符串转换为 json 对象。我正在使用 oracleJet,这是我的代码:
function DashboardViewModel() {
var self = this;
self.lineTypeValue = ko.observable('curved');
var scatterSeries = [];
$.getJSON( "http://localhost:8080/points", function (data) {
console.info(data);
var ch = '{"name":"graphe1","items":'+JSON.stringify(data.results[1])+ '}';
console.info(ch);
console.info(JSON.parse(scatterSeries));
scatterSeries.push(JSON.parse(ch));
});
/* chart data */
this.scatterSeriesValue = ko.observableArray(scatterSeries);
self.lineTypeOptions = [
{id: 'straight', label: 'straight'},
{id: 'curved', label: 'curved'},
{id: 'stepped', label: 'stepped'}, …
Run Code Online (Sandbox Code Playgroud)