android - db.trasaction doesnt wait for callback. Intel Xdk -
i working on creating mobile app web sql database. trying return array 1 function below
getcheckeditems:function(type,itemid){ var optarr=[]; var sql ="select optionid opt mytable familymemberid=" + this.memberid+ " , questionid="+itemid mydb.runquery(sql, function(optionrecords) { if(optionrecords.length>0) { if(type==2) { var optionid=optionrecords[0].opt; optarr.push(optionid); alert(optarr); // alert(optionid+"hello"); } else { for(var i=0;i<optionrecords.length;i++) { optarr.push(optionrecords[i].opt); } } } }); alert(optarr); return optarr; }
but here second alert i.e optarr
shown before alert in transaction. how can make wait db transaction completed before array returned.
i'm no web sql expert, guess you're missing ;
@ end of var sql = ...
line , might causing unexpected behavior.
Comments
Post a Comment