I am using phonegap's database API in my html/css/js code and i have a problem.Although in the index page i manage to create tables,insert data,select and display them,when i proceed to my second html file i can't access anything from the database.I get SQL error 0.Here is my javascript file for the second html page.Any ideas?
var db;
function ondevre (){
alert('a1');
$.ajaxSetup({
crossDomain: true,
xhrFields: {
withCredentials: true
}
});
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
signsql();
function signsql(){
db = window.openDatabase("Database", "1.0", "Cordova Demo", 2*1024*1024);
db.transaction(selectDB, errorCB, successCB);
function errorCB(err) {
alert("Error processing SQL: "+err.code);
}
function successCB() {
alert("YEAH!!!!");
}
function selectDB (tx) {
myname=escape(window.localStorage["myname"]);
var stre='SELECT User_Mail FROM table1 WHERE User_Name="'+myname+'"';
tx.executeSql(stre, [], mnme, function er(e) {alert("error "+e)});
function mnme (tx,result) {
if (result != null && result.rows != null) {
alert(result.rows.length);
for (var i = 0; i < result.rows.length; i++) {
var row = result.rows.item(i);
};
us_mail=row.User_Mail;
}
}
}
};
}
$("#ii").ready (function () {
$("#whole").fadeIn(2500);
ondevre();
});
app.initialize();
Aucun commentaire:
Enregistrer un commentaire