在更新数据库或加载时,我一直在尝试使用加载gif来替换光标。当我的选项卡加载时它确实有效,但是当我从jQuery模式弹出窗口保存时它不会。 当我调试并查看渲染的html时,它告诉我它正在显示它之前调用style =“display:block;”当我让它完成保存时,它会切换回style =“display:none;”下面的代码只是一种品味,对不起,我无法将实际代码从开发网络转移到这里。由于我在一个巨大的应用程序中使用这些弹出窗口进行每次编辑,我真的很想得到加载的gif。
//using jquery to start and stop with ajax
var $loading = $('#waiting').hide();
$(document)
.ajaxStart(function () {
$loading.show();
})
.ajaxStop(function () {
$loading.hide();
});
//my div
<div id="waiting" class="loading-img" style="display:none;"
$("#somePopup").dialog({
autoOpen:false,
height: 'auto',
width: 900,
buttons: { Save: ....
// you get the idea
$ajax({
type:"post",
url: "some procedure",
dataType: "json",
data: DTOvar,
contentType: "application/json",
async: false,
success: function(data){
//refresh main screen and close popup
error : function(errorstuff){
//handle error
}
});
答案 0 :(得分:0)
由于您指定&#34; async:false&#34;,它不会起作用,表示浏览器使用相同的ui线程。 ajaxStart / ajaxStop方法永远不会有机会运行。您最有可能远程同步选项以实现您的需求。