zoukankan      html  css  js  c++  java
  • JqueryMoblie 之 loading

    显示“正在加载........”等字样,并且带有加载图片的显示。

    //显示加载器
    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不会显示。

  • 相关阅读:
    【转】嵌入式程序员应该知道的16个问题
    GetMemory()函数
    Some good questions
    [转]永远做一个有计划的人
    内存分配管理
    c语言面试题(感觉比较好的题目)
    const char*, char const*, char*const的区别
    《论语》《中庸》《大学》经典语录
    洗脑
    python基础之函数参数,名称空间,以及函数嵌套
  • 原文地址:https://www.cnblogs.com/ScorchingSun/p/3899430.html
Copyright © 2011-2022 走看看