我有这个代码
var children;
$.ajax({
url: Routing.generate('snmp_ajax_get_children', {dev: root}),
async: true, type: "GET"
}).done(function(data) {
var children = Array();
for(var i in data) {
children[i] = data[i].split('|');
for (var j in data[i]) {
children[i][j] = $.trim(data[i][j]);
}
}
localStorage.setItem('children', children);
});
children = localStorage.getItem(children);
localStorage.removeItem('children');
我使用localStorage(丑陋,我知道)从回调中获取数据,因为任何其他方法都不适合我(我不知道为什么),有什么建议吗?