我正在使用 PhoneGap SQLite,但我遇到了数据未显示的问题。警报(脚本)显示数据存在,但未显示在主屏幕上。我在代码中犯了什么错误?
在 jQuery 中:
function get_Emp_List() {
$("#employee").empty();
$(location).attr('href', '#emp1');
$.support.cors = true;
$.ajax({
type: "GET",
url: "one.html",
contentType: "text/xml",
dataType: "xml",
data: "",
crossDomain:true,
success: function (data) {
$(data).find("employee").each(function () {
var emp_id = $(this).find('id').text();
var emp_name = $(this).find('short_name').text();
db.transaction(function(transaction) {
transaction.executeSql('INSERT INTO Envy_Emp VALUES((SELECT max(_idEE)+1 FROM Envy_Emp),"'+emp_id+'","'+emp_name+'")',nullHandler,errorHandler);
});
});
ids_Dynamic_Emp_List();
return false;
},
error: function (data) {
alert("error");
}
});
}
/* end Employee list script */
/*ids_Dynamic_Emp_List() method coding Start*/
function ids_Dynamic_Emp_List(){
/*sql start*/
/*sqlite code for dynamic Emp list*/
db.transaction(function(tx){
tx.executeSql('SELECT * FROM Envy_Emp;', [],
function(tx,results){
if (results != null && results.rows != null) {
var myLen=results.rows.length;
for (var i = 0; i < results.rows.length; i++) {
var for_Name = results.rows.item(i).Envy_Emp_Name;
var for_ID = results.rows.item(i).Envy_Emp_ID;
var for_E_ID=results.rows.item(i)._idEE;
/*create table list Dynamically using Sqlitedata base */
var scripts = "<a href='#' data-role='button' data-theme='b' data-inline='true' onclick='get_Menu_List(id);' id='"+for_E_ID+"'>"+for_Name+"</a>";
alert(scripts);
$(".employee1")
.append(scripts)
.trigger('create');
/*create table list Dynamically using Sqlitedata base End*/
}
}
},errorHandler);
}
,errorHandler,nullHandler);
return;
}
在 HTML 中:
<div data-role="page" id="emp1">
<div date-role="content">
<div id="employee" class="employee1"/>
</div>
</div>