为什么我不能填充这个数据库?

时间:2014-04-12 11:30:36

标签: javascript

我正在使用htm5sql库并尝试使用远程json填充数据库。函数getstuff2将json存储在Jsonvar

function getStuff2(num){
$.getJSON('http://whateverorigin.org/get?url=' + encodeURIComponent('http://www.catholic.com/api-radio/' + num) + '&callback=?', function(data){
var Jsonvar = data.contents;
html5sql.process(
     [
        "INSERT INTO catholic (json) VALUES ('" + Jsonvar + "');"
     ],
     function(){
        alert("the data was populated");
        readDB();       
      }, catchError);
return data.contents;
 });
}

function getStuff1(){
$.getJSON('http://whateverorigin.org/get?url=' + encodeURIComponent('http://www.catholic.com/api-radio/latest') + '&callback=?',  function(data){

var obj = data.contents;
obj = JSON.parse(obj);
var latestnum = obj.latest;
//alert('works');
var numbers = new Array(50);
for(i=0; i<50; i++){
x = latestnum - i;
numbers[i] = x;
//alert(numbers);
}
getStuff2(numbers);
return data.contents;
});
}
function catchError(){

}  

getStuff1();

0 个答案:

没有答案