【发布时间】:2015-04-05 04:37:36
【问题描述】:
我有一个 JSON 文件,其中包含:
[{
"title": "title you desire",
"url" : "thisistheurl.com"
},{
"title": "title you desire",
"url" : "thisistheurl.com"
},{
"title": "title you desire",
"url" : "thisistheurl.com"
}]
我现在正在尝试将这些添加到 JS 数组中,并尝试在我的手机上将它们显示为警报:
$.getJSON('links.json', function (json) {
var linkList = [];
$.each(json, function(i, obj) {
linkList.push([obj.title, obj.url]);
});
});
$.each( linkList, function( key, value ) {
alert( value.title + ": " + value.url );
});
但是当我在手机上运行它时,没有显示任何警报。有什么想法我可能做错了吗?
【问题讨论】:
标签: javascript jquery json cordova jquery-mobile