我正在使用类固醇js处理PHone Gap应用。我尝试使用Cordova Storage API获取远程JSON并将其存储在sqlite数据库中。出于某种原因,我无法做到这一点。数据库未填充JSON。这是我的剧本
function getStuff(num) {
$http.jsonp('http://whateverorigin.org/get?url=' + encodeURIComponent('http://catholic.com/api-radio/' + num) + '&callback=JSON_CALLBACK')
.success(function (response) {
var result = angular.fromJson(response.contents);
var JSONvar = result;
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS DEMO');
tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "'+ JSONvar +'")');
}
function errorCB(err) {
alert("Error processing SQL: "+err.code);
}
function successCB() {
alert("success!");
}
var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
db.transaction(populateDB, errorCB, successCB);