小编Chr*_*ris的帖子

在等待AJAX​​响应时加载gif

我想知道我是否能得到一些指示.我试图在从ajax请求获得响应时使用加载gif.我遇到的问题是它在发送电子邮件时不会显示gif.

我在这里查看了几个页面试图找到解决方案,但它们似乎都没有工作.这是我看过的网页:而jQuery的AJAX运行加载GIF图像显示加载图片,同时用后阿贾克斯执行,而$就显示加载图片

我使用以下代码来尝试实现此目的:

$("#loading").bind("ajaxStart", function(){
$(this).show();
}).bind("ajaxStop", function(){
$(this).hide();
});
Run Code Online (Sandbox Code Playgroud)

这没有显示gif,我也尝试了以下内容:

$.ajax({
 type: "POST",
 url: "contact1.php",
 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;
});
function …
Run Code Online (Sandbox Code Playgroud)

ajax jquery

15
推荐指数
1
解决办法
4万
查看次数

标签 统计

ajax ×1

jquery ×1