我正在研究从PHP文件中以JSON格式获取数据库信息的小应用程序。我正在尝试编写alert和jquery ajax调用,但两者都没有在app中工作/执行。但是,当我同时检查浏览器然后它显示。我是Apache cordova平台的新手。有人可以就我的问题回复我吗?如何在应用中解决这些基本问题。
平台:ios app。 - 在--emulator上运行
等待你的回复。
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
$("#defaultsetlocation").html("hello added new text");
alert("i am alert");
try
{
navigator.notification.alert('Hello', ok, 'Title', 'Button!');
}
catch(e)
{
alert("doesn't support!!");
}
console.log('Received Event: ' + id);
}
};
app.initialize();