我正在使用AJAX和Local Storage for Phonegap实现Highcharts。我有两个函数几乎相同的代码,但 eval()仅在一个函数中工作。
它适用于以下功能
var teamactivitygameGraph = window.localStorage.getItem("teamactivitygameGraph");
AGW = JSON.parse(teamactivitygameGraph);
var Gdata = AGW.data;
//alert(Gdata);
json = "[" + Gdata + "]";
//alert(json);
//console.info(json);
var myData = eval(json);
myData.push({
name: 'yellowline',
visible: false,
showInLegend: false,
data: yellowLineData
});
alert('Weekly: '+myData);
在警报时,它输出以下内容,这很棒:
Weekly: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
在下面的函数中,它在chrome n firefox调试控制器中出错。匿名函数在eval()上
var teamdayactivitygameGraph = window.localStorage.getItem("teamdayactivitygameGraph");
AGD = JSON.parse(teamdayactivitygameGraph);
var Gdata = AGD.data;
var json = "[" + Gdata + "]";
//alert(json);
//console.info(json);
var myData = eval(json);
myData.push({
name: 'yellowline',
visible: false,
showInLegend: false,
data: yellowLineData
});
alert('Daily: '+myData);
此功能不会发出任何警报。
任何帮助都会很棒!提前谢谢