when I execute this function it displays me the following error:
"JavaScript execution exceeded timeout" how I can solve this problem by using settimeout () or what?
I retrieve 3000 line from json file.
applyChanges_PhrasesTypes: function(employees, callback) {
//alert("fonction apply chamges est lancer PhrasesTypes");
this.db.transaction(
function(tx) {
var l = employees.length;
var sql =
"INSERT OR REPLACE INTO PhrasesTypes (IdPhrase, IdPhraseES, IdRubrique, IdTypeTravauxAffichage, Phrase, AidePhrase, AvertissementPhrase,OrdrePhrase,QuotationParDefaut,Published) " +
"VALUES (?,?,?,?,?,?,?,?,?,?)";
//alert('Inserting or Updating in local database: PhrasesTypes');
var e;
for (var i = 0; i < l; i++)
{
e = employees[i];
log(i);
//log("Ligne "+ i +" est inserer de id PhrasesTypes = "+e.IdPhrase);
var params = [e.IdPhrase, e.IdPhraseES, e.IdRubrique, e.IdTypeTravauxAffichage, e.Phrase, e.AidePhrase, e.AvertissementPhrase,e.OrdrePhrase,e.QuotationParDefaut,e.Published];
tx.executeSql(sql, params);
}
log('sync_PhrasesType shronization terminée avec (' + l + ' items sync_PhrasesTypeshronié)');
},
this.txErrorHandler_PhrasesTypes,
function(tx)
{
callback();
}
);
}
@lgor: here is my code but only 2000 insert line, and terminates with an error,
JavaScript execution exceeded timeout javascript
InsertPortion: function(tx)
{
var l = Math.min(gEmployees.length, gIter + 300);
log('aaaaaaaaaaaaaaaaaaaaaaaa---'+l)
for (; gIter<l ; gIter++)
{
log('do insert here');
var sql =
"INSERT OR REPLACE INTO PhrasesTypes (IdPhrase, IdPhraseES, IdRubrique, IdTypeTravauxAffichage, Phrase, AidePhrase, AvertissementPhrase,OrdrePhrase,QuotationParDefaut,Published) " +
"VALUES (?,?,?,?,?,?,?,?,?,?)";
//alert('Inserting or Updating in local database: PhrasesTypes');
var e;
e = gEmployees[gIter];
log(gIter);
//log("Ligne "+ i +" est inserer de id PhrasesTypes = "+e.IdPhrase);
var params = [e.IdPhrase, e.IdPhraseES, e.IdRubrique, e.IdTypeTravauxAffichage, e.Phrase, e.AidePhrase, e.AvertissementPhrase,e.OrdrePhrase,e.QuotationParDefaut,e.Published];
tx.executeSql(sql, params);
}
if (gIter < gEmployees.length)
{
log('sync_PhrasesType shronization terminée avec (' + gIter+ ' items sync_PhrasesTypeshronié)');
setTimeout(dao3.InsertPortion(tx), 100);
}
else
{
gEmployees = null;
gIter = 0;
}
},
applyChanges_PhrasesTypes: function(employees, callback) {
//alert("fonction apply chamges est lancer PhrasesTypes");
this.db.transaction(
function(tx)
{
gIter = 0;
gEmployees = employees;
dao3.InsertPortion(tx);
},
this.txErrorHandler_PhrasesTypes,
function(tx)
{
callback();
}
);
},