jeudi 17 septembre 2015

Insert Remote Data into PhoneGap/Cordova SQLite DB

I am trying to INSERT my data from remote DB into my local SQLite database. The code is:

 function getpeople(tx) {
     $.getJSON('http://ift.tt/1W4Kuiz?', function (data) {
         $.each(data.result, function (i, item) {
             db.transaction(function (tx) {
                 tx.executeSql("INSERT OR REPLACE INTO db_user (user_id, username, time, distance) VALUES (?,?,?,?)", [1, item.user_login, item.time, item.distance], function (tx, res) {
                     alert('success');
                 });
             });
         });
     });
 }

The problem seems like my getJSON isn't firing. So I don't see my alert "Success".

Could anybody help with this issue?

Aucun commentaire:

Enregistrer un commentaire