码迷,mamicode.com
首页 > Web开发 > 详细

jquery mobile中显示加载中提示框和关闭提示框

时间:2014-06-30 15:12:48      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   strong   数据   

在jquery mobile开发中,经常需要调用ajax方法,异步获取数据,如果异步获取数据方法由于网速等等的原因,会有一个反应时间,如果能在点击按钮后数据处理期间,给一个正在加载的提示,客户体验会更好一些。

先看两个方法,显示和关闭,方法来自于参考:http://blog.csdn.net/zht666/article/details/8563025

<script>  
//显示加载器  
function showLoader() {  
    //显示加载器.for jQuery Mobile 1.2.0  
    $.mobile.loading(show, {  
        text: 加载中..., //加载器中显示的文字  
        textVisible: true, //是否显示文字  
        theme: a,        //加载器主题样式a-e  
        textonly: false,   //是否只显示文字  
        html: ""           //要显示的html内容,如图片等  
    });  
}  
  
//隐藏加载器.for jQuery Mobile 1.2.0  
function hideLoader()  
{  
    //隐藏加载器  
    $.mobile.loading(hide);  
}  
</script>  

然后在ajax中调用:

//获取进度
function InsertStatus(matterID, obj) {
    var a = $(obj).parent().parent().parent();
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/ToDoList/InsertStatus/?matterID=" + matterID,
        beforeSend: function () {         
            showLoader();
        },
        complete:function(){       
            hideLoader();
        },
        success: function (msg) {
            if (msg > 0) {
                $("#popdiv").text("获取进度成功");
            } else {
                $("#popdiv").text("获取进度失败");
            }
            //弹出提示信息
            $("#GettingProgress").attr(data-rel, dialog);
            $("#GettingProgress").trigger(create);
            $("#popdiv").popup("open");
            setTimeout(function () { $("#popdiv").popup("close"); }, 2000);
        }
    });

}

这样就可以在数据处理过程中,有加载中的效果。

jquery mobile中显示加载中提示框和关闭提示框,布布扣,bubuko.com

jquery mobile中显示加载中提示框和关闭提示框

标签:style   blog   http   color   strong   数据   

原文地址:http://www.cnblogs.com/hiflora/p/3816212.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!