上传或提交等待过程图标loading.gif的实现

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title></title>
    <style>
.loadingWrap{
	position:fixed;
	top:0;
	left:0;
	width:100%;
	height:100%;
	z-index:300;
	background-image:url(loading.gif);
	background-repeat:no-repeat;
	background-position:center center;
	background-color:#000;
	background-color:rgba(0,0,0,0.5);
	filter:alpha(opacity=50);
}
</style>
    
</head>
<body>
	测试 加载中。。。
    <div class="loadingWrap"></div>
</body>
</html>


ajax提交表单后的等待,应当做如下处理:

$.ajax(  
        type:"post",  
        url:basePath + “xxx/xxx/xx.do”,  
        data:{"idMerchant":idMerchant},  
        dataType:"json",  
        success:function(data){//后端返回json格式的字符串  
            if(!data){//成功不需要提示
                alert("提交失败!");
             }
        },  
        error:function(){  
            alert("查询异常,请稍后再试或联系管理员。。。");  
        },
        beforeSend: function(){  
            $("<div class="loadingWrap"></div>").appendTo("body");  
        }, 
        complete: function(){  
            $(".loadingWrap").remove();  
        }
  
    }); 

beforeSend和complete中处理!!!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章