但是,如果我單擊後退按鈕然後嘗試刷新頁面,則使用最新的jQuery移動版(「http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js)和jquery(http://code.jquery.com/jquery-1.9.1.min.js)以及我的pagecreate事件大多數時間工作, 。正在顯示我可以看到請求使用Firebug發生,但我看不出爲什麼JSON的結果不是在頁面上設置GetJson不會一直返回json結果
感謝
$(document).on("pagecreate", "#checkout51", function(event, ui) {
thisPage = $(this);
loadPageContent("checkout51.html", function(data) {
$(thisPage).prepend(data);
});
});
$(document).on("pageshow", "#checkout51", function(event, ui) {
$.mobile.loadingMessage = "Please wait - loading coupons ...";
var couponslist = $('#couponslist');
$.mobile.showPageLoadingMsg();
var url = "http://www.test.com/request.php?";
$.getJSON(url, {
limit: "100",
coupon_source : "Checkout51"
}, function (data) {
var listContent = "";
listContent += "<li data-role='list-divider'>Checkout51 Coupons</li>";
$.each(data, function(index, value){
listContent += "<li><h2><a class='ui-link-inherit' href='coupondetails.html?id=" + value.coupon_id + "'>" + value.name + "</a></h2></li>";
});
$('#couponslist').empty().append(listContent).listview('refresh');
})
.error(function() { alert("Error while request processing"); })
.complete(function() {
$.mobile.hidePageLoadingMsg()
});
});
使用這個作爲HTML。!
<div class="fixed-header" data-position="fixed" data-tap-toggle="false" data-role="header" data-theme="b">
<a href="#" data-theme="b" class='ui-btn-left' data-icon='arrow-l'>Back</a>
<h1>Checkout51 Coupons</h1>
<a href="#" data-role="button" data-theme="b" data-icon="home" data-iconpos="notext"></a>
</div>
<div data-role="content" data-theme="c"><br /><ul id="couponslist" data-role="listview" role="listbox"></ul><br /></div>
<div data-role="footer" data-position="fixed" data-id="footer"><div data-role="navbar"><ul><li><a href="index.html" id="menu1" data-role="button" data-icon="home">Home</a></li> <li><a href="search.html" id="menu2" data-role="button" data-icon="search">Search</a></li><li><a href="subscribe.html" id="menu3" data-role="button" data-icon="info">Subscribe</a></li></ul></div></div><!-- /footer -->
我將不勝感激任何幫助 - 這是一個Phonegap應用程序,但我需要看到這一貫的使用瀏覽器。
嘗試'pagebeforeshow'而不是'pagecreate'。 – Omar