JqueryMoblie 之 loading

來源:互聯網
上載者:User

標籤: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不會顯示。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.