我正在为 ios 开发一个 App 框架 + phonegap 构建应用程序。当一个 id #item1 的面板加载时,我不想在本地获取数据并将其写入页面。我用这个:
$('#item1').on("loadpanel", function(){
$.ajax({
type:"GET",
url:"data/mydata.json",
contentType:"application/json",
success:function(data){
console.log(data.cat);
alert(data.cat);
$.ui.setTitle(data.cat);
$.each(data.entries, function( index, value ) {
$('ul.list').append('<li data-filter="' + value.title + '"><a href="#details/'+ index +'/1">' + value.title + '</a></li>')
});
$(".list").filterList();
},
error: function (xhr, ajaxOptions, thrownError) {
alert("errorstatus: " + xhr.status + " ajaxoptions: " + ajaxOptions + " throwError: " + thrownError);
}
});
});
这在浏览器中工作得很好,但是当我使用 phonegap build 为 ios 打包应用程序时,页面上没有任何内容,并且警报语句显示未定义。这可能与 config.xml 中的 phonegap 访问标记有关,因此我将它们也粘贴在这里:
<access origin="*" />
<access origin="*"/>
非常感谢所有帮助!