在ajax中等待光标问题 [英] Wait cursor issue in ajax

查看:83
本文介绍了在ajax中等待光标问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在asp按钮的onclientclick事件中添加了ajax调用。 onclientclick的第一行是加载等待光标。但等待光标只是在ajax调用结束后才在最后加载



如果我用j12中的代码检查F12。等待光标正在正确加载。但是在运行时没有正确加载



javascript中的代码:

函数Validation_load(){

document.getElementById ('divLoading')。style.display ='block';

$ .ajax({

//呼叫声明;

}) ;

}



asp文件中的代码

< asp:Button ID =btnSaverunat = serverTabIndex =8OnClientClick =return Validation_load(); Text =SaveWidth =100px/>

< div id =divLoadingclass =modalrunat =serverstyle =text-align:center; display:无>

< asp:面板ID =Panel5runat =服务器>















< asp:Label ID = Label2Text =EnableViewState =falserunat =server>





< img src =资源/等待.icotitle =[请等待页面加载...]

alt =正在加载....../>


< br $>








模态的Css



.modal {

position:fixed;

top:0;

left:0;

background-color:白色;

z-index:99;

opacity:0.8;

filter:alpha(opacity = 80) ;

-moz-opacity:0.8;

min-height:100%;

宽度:100%;

}

解决方案

.ajax({

//致电报表;

});

}



asp文件中的代码

< asp:按钮ID =btnSaverunat =server TabIndex =8OnClientClick =return Validation_load(); Text =SaveWidth =100px/>

< div id =divLoadingclass =modalrunat =serverstyle =text-align:center; display:无>

< asp:面板ID =Panel5runat =服务器>















< asp:Label ID = Label2Text =EnableViewState =falserunat =server>





< img src =资源/等待.icotitle =[请等待页面加载...]

alt =正在加载....../>


< br $>








模态的Css



.modal {

position:fixed;

top:0;

left:0;

background-color:白色;

z-index:99;

opacity:0.8;

filter:alpha(opacity = 80) ;

-moz-opacity:0.8;

min-height:100%;

宽度:100%;

}


发送AJAX请求时使用 beforeSend 属性。请尝试以下代码:

 


.ajax({
type: POST
url: script.aspx
data:{},
beforeSend: function (){

I have added the ajax call to the onclientclick event of asp button. The first line of onclientclick is to load wait cursor. But the wait cursor is getting loaded only at the last after the ajax call has ended

If i check with the code in javascript with F12. The wait cursor is getting loaded correctly. But not loading properly at runtime

Code in javascript:
function Validation_load() {
document.getElementById('divLoading').style.display = 'block';
$.ajax({
//Call statements;
});
}

Code in asp file
<asp:Button ID="btnSave" runat="server" TabIndex="8" OnClientClick="return Validation_load();" Text="Save" Width="100px"/>
<div id="divLoading" class="modal" runat="server" style="text-align: center; display: none">
<asp:Panel ID="Panel5" runat="server">









<asp:Label ID="Label2" Text="" EnableViewState="false" runat="server">



<img src="Resources/wait.ico" title="[Please wait while the page is loading...]"
alt="Loading..." />






Css for modal

.modal {
position: fixed;
top: 0;
left: 0;
background-color: White;
z-index: 99;
opacity: 0.8;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
min-height: 100%;
width: 100%;
}

解决方案

.ajax({
//Call statements;
});
}

Code in asp file
<asp:Button ID="btnSave" runat="server" TabIndex="8" OnClientClick="return Validation_load();" Text="Save" Width="100px"/>
<div id="divLoading" class="modal" runat="server" style="text-align: center; display: none">
<asp:Panel ID="Panel5" runat="server">









<asp:Label ID="Label2" Text="" EnableViewState="false" runat="server">



<img src="Resources/wait.ico" title="[Please wait while the page is loading...]"
alt="Loading..." />






Css for modal

.modal {
position: fixed;
top: 0;
left: 0;
background-color: White;
z-index: 99;
opacity: 0.8;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
min-height: 100%;
width: 100%;
}


Use beforeSend attribute when sending AJAX request. Please Try below code:


.ajax({ type: "POST", url: "script.aspx", data: {}, beforeSend: function() {


这篇关于在ajax中等待光标问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆