標籤:color os io ar cti 代碼 html amp
顯示“正在載入........”等字樣,並且帶有載入圖片的顯示。
//顯示載入器
function showLoader() {
$.mobile.loading(‘show‘, {
text: ‘正在提交...‘, //載入器中顯示的文字
textVisible: true, //是否顯示文字
theme: ‘d‘, //載入器主題樣式a-e
textonly: false, //是否只顯示文字
html: "" //要顯示的html內容,片等
});
}
隱藏“正在載入......”和表徵圖
function hideLoader()
{
//隱藏載入器
$.mobile.loading(‘hide‘);
}
請求如下:
showLoader();
$.ajax({
type : "post",
async : true,
url : "test.jsp?orderId="+orderData.orderId+"&sinalSign="+sinalSign,
dataType : "json",
success : function(json) {
if (json.returnState) {
} else {
$("#warnSubmit").html("<font color=‘red‘>(出租失敗)</font>");
}
hideLoader();
},
error : function() {
$("#warnSubmit").html("<font color=‘red‘>(出租失敗)</font>");
hideLoader();
}
});
註:在一個請求中,往往在請求之前顯示loading,在獲得結果後隱藏loading,應當注意的是,由於請求是非同步,所以需要在請求發起之前調用showLoader,在請求中的結果處理中調用hideLoader,而不是在請求代碼外調用hideLoader,否則loading不會顯示。