【发布时间】:2018-01-16 12:07:45
【问题描述】:
如何在 Main.Master 页面的 asp.net 项目中使用 jquery 显示加载 Gif 动画?每当需要时间时,我都想展示这个 Gif。
我在互联网上搜索过,但他们只为一个控件显示此加载图像。这就是为什么我需要将此 jquery 保留在一个地方(即:在母版页中)并希望在所有内容页面上使用它,只要它花费太多时间来加载页面(第一次加载页面或单击按钮或任何事件)花时间)
$.ajax({
type: "POST",
url: "~/Jobs/ExportJobEntry.aspx",
data: dataString,
beforeSend: loadStart,
complete: loadStop,
success: function() {
$('#form').html("<div id='msg'></div>");
$('#msg').html("Thank you for your email. I will respond within 24 hours. Please reload the page to send another email.")
},
error: function() {
$('#form').html("<div id='msg'></div>");
$('#msg').html("Please accept my apologies. I've been unable to send your email. Reload the page to try again.")
}
return False);
});
$(document).ready(function () {
$(document).ajaxStart(function () {
$("#loading").show();
}).ajaxStop(function () {
$("#loading").hide();
});
});
我使用了这段代码,但它不起作用
【问题讨论】:
-
如果在
$.Ajax之前开始并在success内结束是否有效?就像一个测试。 -
这里的答案可能对您有所帮助:stackoverflow.com/questions/31199304/…