【发布时间】:2012-12-05 00:59:50
【问题描述】:
我想加载一个外部页面(因此不使用查询移动设备中的 ajax),问题是当我使用通过单击链接标签激活的功能时,并且在此功能中我有一个 INSERT 到数据库中,该链接在脚本写入数据库之前被跟踪。
这里是部分代码:
$('#aggiungiClienteRubrica').click(function() {
db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
db.transaction(function(tx){
var sql = 'INSERT INTO CLIENTI (nome, cognome) VALUES ("'+$('#nome').val()+'", "'+$('#cognome').val()+'")';
tx.executeSql(sql)}, errorCB);
});
在 html 文件中我只有一个这样的标签:
<a id="aggiungiClienteRubrica" href="../client/consultClients.html" data-role="button" data-theme="b" rel="external">Add client</a>
所以问题是,我可以执行 javascript,但是异步调用将插入到 db 中的记录没有被执行并且 ../client/consultClients.html 页面被加载
我怎样才能让它在工作完成后跟随链接??
【问题讨论】:
标签: jquery cordova jquery-mobile asynchronous