0
想象一下以下數據集:
{"FakeEconomy":{
"2016-04-05":5651694,
"2016-04-06":5513759,
"2016-04-07":5410169,
"2016-04-08":5094142,
"2016-04-09":4768829,
"2016-04-10":5101458,
"2016-04-11":5776419,
"2016-04-12":5692041,
"2016-04-13":5568383,
"2016-04-14":5555027,
"2016-04-15":5116844,
"2016-04-16":4653882,
"2016-04-17":5112466,
"2016-04-18":5764588
}}
當我使其通過jQuery的每一個功能,它工作正常,但隨後拋出一個隨機:
Uncaught TypeError: Cannot read 'visits' of undefined
以下是jQuery代碼:
console.log(dataset['visits']); // Prints the data above
$.each(dataset['visits'], function(index,value) {
pageName = index;
$.each(dataset['visits'][index], function(index,value) {
timeline.push(index);
visits_data.push(parseInt(value));
console.log(timeline);
})
});
是什麼造成的錯誤?
錯誤不是來自此代碼。它來自其他地方。對異常使用暫停來檢測這一點。 –
@RajaprabhuAravindasamy你是一個天才。發現程序提出錯誤的原因是因爲我將jQuery準備好的功能放在js文件中而不是html文件中,並且因爲js文件比HTML運行速度快,所以它擋住了磚塊 – Adib
正常工作:https:// jsfiddle.net/rayon_1990/gvzu13un/ – Rayon