javascript - How to get result of querySuccess in phonegap -
i need result var in javascript of querysuccess in phonegap code
function querydb(tx) { tx.executesql('select * dmomm1', [], querysuccess, errorcb); } function querysuccess(tx, results) { var len = results.rows.length; console.log("demo table: " + len + " rows found.");
i need 'message'
var message = results.rows.item(0).data; } function errorcb(err) { alert( "error" ); } function successcb() { var db = window.opendatabase("database", "1.0", "cordova demo", 200000); db.transaction(querydb, errorcb); console.log('succescb'); } function ondeviceready() { navigator.geolocation.getcurrentposition(onsuccess, onerror); var db = window.opendatabase("database", "1.0", "cordova demo", 200000); db.transaction(successcb); console.log('odevready'); } function onsuccess(position) { $.get('http://adress.com/coord.php? name=
i need put here 'message'
&lati='+position.coords.latitude+'&longi='+position.coords.longitude); } function onerror(error) { alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n'); }
can wrong?
define var message;
outside of function (instead of inside function have above) , in function use:
message = results.rows.item(0).data;
instead of
var message = results.rows.item(0).data;
this scoping issue.
Comments
Post a Comment