Cordova – Reload page in PhoneGap

I am updating the table value, and then I want to display the updated table value in phonegap. For this, I am using the reload() method, but when I use this method, the table does not Update (the code related to the database is not executed), but is being reloaded.
Can anyone help me how to use reload or not to use reload to display the updated value of the table..? My code is

function save()
{ var v=0;
//alert("save button");< br />// alert("global :"+global.length);
for(var n=0;n<(global.length+l);n++)
{
/ /alert("hi");
var x1=$('input.current')[n];
//alert($(x1).val());
if ($(x1).val()=="0")
{
// alert("compare");
var y1=$('input.new')[n ];
newaloc[v]=$(y1).val();

//alert(newaloc[v]);
v++;
}< br /> }
//var polno=init();

var db = window.openDatabase("DataBase", "3.6.22", "test", 200000);< br />


db.transaction(function(transaction)
{

transaction.executeSql('SELECT * FROM POLICIES_DET WHERE POLICY_NUMBER="' +polno+'";',[],
function(transaction, result)
{
if (result != null && result.rows != null)
{
// alert(result.rows.length);
for (var i = 0; i {

var row = result.rows.item(i);

// $("#table").append(""+row.FUND_DESC+" ");
fund=row.INSURED_AMOUNT;
//alert(fund);

}

}

},errorHandler);
},errorHandler,nullHandler);
db.transaction(insert, errorCB, successCB);

al//ert( "after insert");


//alert("no of records:"+gl obal.length);
for(var i=0;i {
var it=$('input.new')[i];
var k=$(it).val();
//if(k.length>0)
//{
// alert("new allocation loop");
xx.push(k);
//alert(xx[v]);
v++;
// }
}
v=0 ;
db.transaction(function(transaction)
{
// alert("updation");
for(var j=0;j {
var c=xx[j];
//alert(c);
var g=global[j];
//alert(g) ;
if(c.length>0)
{
var vl=fund*(c/100);
//alert(vl);
transaction. executeSql('UPDATE FUND_DET SET ALLOC_PERCNT="'+c+'",FUND_VALUE="'+vl+'"WHERE POLICY_NUMBER="'+polno+'"AND FUND_DESC="'+g+'";',[],
function(transaction, result)
{
if (result != null && result.rows != null)
{
//al ert("Test other way");
for (var i = 0; i {
var row = result.rows.item(i) ;

}

}

},errorHandler);
}} },errorHandler,nullHandler);
< br />location.reload();
}

When I write It works fine when entering position.reload()
Like this

db.transaction(function(transaction)
{
/ / alert("updation");
for(var j=0;j {
var c=xx[j];
// alert(c);
var g=global[j];
//alert(g);
if(c.length>0)
{
var vl=fund*(c/100);
//alert(vl);
transaction.executeSql('UPDATE FUND_DET SET ALLOC_PERCNT="'+c+'",FUND_VALUE="'+vl+'" WHERE POLICY_NUMBER="'+polno+'"AND FUND_DESC="'+g+'";',[],
function(tra nsaction, result)
{
if (result != null && result.rows != null)
{
//alert("Test other way");
for (var i = 0; i {
var row = result.rows.item(i);

}

}
location.reload();

},errorHandler);
}} },errorHandler,nullHandler);

}

I am updating the table value, and then I want to display the updated table value in phonegap. For this, I am using the reload() method, but when I use In this method, the table is not updated (the code related to the database is not executed), but is being reloaded.
Can anyone help me how to use reload or not to use reload to display the updated value of the table..? My code is

function save()
{ var v=0;
//alert("save button");< br />// alert("global :"+global.length);
for(var n=0;n<(global.length+l);n++)
{
/ /alert("hi");
var x1=$('input.current')[n];
//alert($(x1).val());
if ($(x1).val()=="0")
{
// alert("compare");
var y1=$('input.new')[n ];
newaloc[v]=$(y1).val();

//alert(newaloc[v]);
v++;
}< br /> }
//var polno=init();

var db = window.openDatabase("DataBase", "3.6.22", "test", 200000);< br />


db.transaction(function(transaction)
{

transaction.executeSql('SELECT * FROM POLICIES_DET WHERE POLICY_NUMBER="' +polno+'";',[],
function(transaction, result)
{
if (result != null && result.rows != null)
{
// alert(result.rows.length);
for (var i = 0; i {

var row = result.rows.item(i);

// $("#table").append(""+row.FUND_DESC+" ");
fund=row.INSURED_AMOUNT;
//alert(fund);

}

}

},errorHandler);
},errorHandler,nullHandler);
db.transaction(insert, errorCB, successCB);

al//ert( "after insert");


//alert("no of records:"+globa l.length);
for(var i=0;i {
var it=$('input.new')[i];
var k=$(it).val();
//if(k.length>0)
//{
// alert("new allocation loop");
xx.push(k);
//alert(xx[v]);
v++;
// }
}
v=0 ;
db.transaction(function(transaction)
{
// alert("updation");
for(var j=0;j {
var c=xx[j];
//alert(c);
var g=global[j];
//alert(g) ;
if(c.length>0)
{
var vl=fund*(c/100);
//alert(vl);
transaction. executeSql('UPDATE FUND_DET SET ALLOC_PERCNT="'+c+'",FUND_VALUE="'+vl+'"WHERE POLICY_NUMBER="'+polno+'"AND FUND_DESC="'+g+'";',[],
function(transaction, result)
{
if (result != null && result.rows != null)
{
//alert ("Test other way");
for (var i = 0; i {
var row = result.rows.item(i);

}

}

},errorHandler);
}} },errorHandler,nullHandler);

location.reload();
}

When I write the location in the function.reload() it works fine
Like this

db.transaction(function(transaction)
{
// alert("updation");
for (var j=0;j {
var c=xx[j];
//alert(c);
var g=global [j];
//alert(g);
if(c.length>0)
{
var vl=fund*(c/100);
//alert(vl);
transaction.executeSql('UPDATE FUND_DET SET ALLOC_PERCNT="'+c+'",FUND_VALUE="'+vl+'"WHERE POLICY_NUMBER="'+polno+'"AND FUND_DESC=" '+g+'";',[],
function(transaction, result)
{
if (result != null && result.rows != null)
{
//alert("Test other way");
for (var i = 0; i {
var row = result.rows.item(i);

}

}
location. reload();

},errorHandler);
}} },errorHandler,nullHandler);

}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3747 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.