0
我試圖用phonegap,jquerymobile和JSON(來自WordPress的json API)構建一個應用程序。我在這裏使用代碼,它適用於我,它顯示最近發佈的列表(index.html)。Phonegap應用程序不顯示下一頁
<script type="text/javascript">
var wpAPI = "http://myurl.nl/api/get_recent_posts/";
$(document).on('pagebeforeshow', '#index', function(){
$.getJSON(wpAPI, function(result) {
$.each(result.posts, function(i, item) {
var html = '<li><a href="post.html?post_id='+ item.id +'"><img src="'+ item.thumbnail +'"><h2>' + item.title + '</h2><p>' + item.excerpt + '</p></a></li>';
$(".container>ul").append(html);
});
$("#list").listview('refresh');
});
});
</script>
問題是,當我嘗試打開時,我導出應用程序爲Android的post.html不顯示任何職位(post.html)之一。
所以我認爲是令人耳目一新的東西,但也許別的東西希望有人能幫助我。
<script>
function readSinglePost (url,container){
var postId = window.location.search;
var URL = 'http://myurl.nl/api/get_post/'+ postId + '';
jQuery.ajax({
url: URL,
dataType: 'json',
success: function(data) {
console.log(data);
$('.container').html("<h3>" + data.post.title + "</h3>" + data.post.content + "");
}
});
}
$(document).ready(function(){
readSinglePost (URL,'.container');
});
</script>
這項工作的一部分是問題。它工作從索引到類別,但不是從category.html post.html我認爲必須重新加載(在readSinglePost函數)的東西在瀏覽器中的作品,但不是在應用程序 –
添加data-ajax =「false」屬性在你通過href鏈接的每個錨標籤中。並chek這個網址'http://myurl.nl/api/get_post/'+ postId +'' – Ved
奇怪的是我建立它在尾聲和它的工作原理,但是當我用build.phonegap.com導出它並安裝它在我的設備上不起作用。德列表視圖(index.html)的作品和鏈接到所有類別的也只顯示帖子不工作:(我將添加完整的html代碼 –