你的位置:首页 > ASP.net教程

[ASP.net教程]ajax等待(比较慢时)(显示图片)


html页面

<div id="loading-mask"></div>

<div id="div_wait_wait_wait"  align="center"><img src="../Content/login/jz.gif" /></div>

样式

#loading-mask {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        z-index: 20000;
        background-color:#000;
        filter:alpha(opacity=50);  
        -moz-opacity:0.5;  
        -khtml-opacity: 0.5;  
        opacity: 0.5;  
    }
#div_wait_wait_wait
{
    position:absolute;
    top:50%;
    left:50%;
    margin:-100px 0 0 -150px;
    width:300px;
    height:200px;
    z-index:99;
}

js代码:

$.ajax({
        type: method,
        async: Isasync,
        cache: Iscache,
        data: key_value,
        url: handleUrl,
        beforeSend: function () {

    //ajax请求开始时
            $("#div_wait_wait_wait").show();
          

    $("#loading-mask").show();
        },
        complete: function () {

    //ajax请求完成时
            $("##div_wait_wait_wait").hide();
            $("#loading-mask").hide();
        },
        dataType: dataType,//text返回文本,json返回记录集
        success: Successfunction
    })