0
私の問題は本当に奇妙です。私はphonegapで働いています。javascript変数からjsonを取得して読み込む
「krijgSpellen」という名前の関数があります。
// Wait for PhoneGap to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady() {
readFile();
var options = { frequency: 3000 };
watchID = navigator.geolocation.watchPosition(onSuccess, onError, options);
krijgSpellen(); <--
}
が、ここで奇妙な部分があり、私はこれを行う:私はとき、「デバイス準備完了」そうのようなその関数を呼び出す
動作しますが、function krijgSpellen(){
$.getJSON("gegevens.txt",function(result){
// Get all the games
$.each(result.games, function(){
$(".gamelijst").append("<li><a href='' id=" + this.id + " data-theme='a'>"+ this.game + "</a></li>");
});
$(".gamelijst, $.mobile.activePage").listview('refresh');
});
};
私はこれを行うとき:
をfunction krijgSpellen(){
$.each(jsonopgehaald.games, function(){
$(".gamelijst").append("<li><a href='' id=" + this.id + " data-theme='a'>" + this.name + "</a></li>");
});
$(".gamelijst, $.mobile.activePage").listview('refresh');
};
これは動作しません。ハイパーリンクに同じコードがあり、ハイパーリンクをクリックすると機能します。そして私は本当にそれが動作しない方法が必要です。
jsonopgehaald = {"games":[{"id":"2","name":"bartje","photo":"photo2.png","description":"kimpe","length":"is","totalDownloads":"0","totalFinished":"0","locations":[{"id":"3","name":"loc21","photo":"loc21.jpg","description":"loc21","FK_Game_id":"2","lat":"51.0000","long":"4.0000","status":"0"},{"id":"5","name":"loc22","photo":"loc22.jog","description":"locatie 22","FK_Game_id":"2","lat":"51.2330","long":"40.2222","status":"1"}]},{"id":"3","name":"aa","photo":"photo3.jPg","description":"aa","length":"aa","totalDownloads":"0","totalFinished":"3","locations":[{"id":"4","name":"loc4","photo":"loc4.jpg","description":"loc4","FK_Game_id":"3","lat":"51.2191","long":"4.4021","status":"0"}]}]}
ありがとうございます!できます –