html等待ajax返回,ajax提交后台开始到返回之间显示等待提示

 
 

此功能完全是jandy所实现的,这里是总结以便以后遇到类似的功能时有例子参考!在这里非常非常感谢jandy!

1、用到的js

function topLoading() {

if(document.getElementByIdx_x("topLoadingDiv")==null ||

document.getElementByIdx_x("topLoadingDiv")==undefined) {

document.write("

class='top_loading'>

src='../images/loading.gif'/>

");

}

document.getElementByIdx_x("topLoadingDiv").className="top_loading";

document.getElementByIdx_x("topLoadingDiv").style.left=(document.documentElement.clientWidth-32)/2+"px";

document.getElementByIdx_x("topLoadingDiv").style.top=(document.documentElement.clientHeight-32)/2+"px";

}

function topLoaded() {

if(document.getElementByIdx_x("topLoadingDiv")!='null'

&&

document.getElementByIdx_x("topLoadingDiv")!=undefined) {

document.getElementByIdx_x("topLoadingDiv").className="top_loaded";

}

}

2、用到的css

div.top_loading{background:url('../images/loading.gif')

no-repeat;width:32px;height:32px;top:100px;left:100px;background-color:transparent;position:fixed;z-index:10000;}

div.top_loaded{width:1px;height:1px;background-color:transparent;display:none;}

3、用到的html

// 调用ajax之前

topLoading();

$.getJSON(url, null, function(data) {

obj.disabled=false;

if (data == "error") {

alert(opeContent+"失败!");

} else if (data == "succ"){

// 2、根据返回结果(成功或者失败),重写load该流程对应的所有组件

alert(opeContent+"成功!");

reloadListDetail(obj);

} else {

alert(data);

reloadListDetail(obj);

}

// ajax返回之后

topLoaded();

});

4、用到的图片:随便从网上下一个你所喜欢的即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值