将加载图像添加到 jquery ajax 帖子中
我有以下 javascript 通过 ajax 发布表单而不刷新屏幕。由于帖子需要一段时间,我想在处理过程中添加加载图像。
我看到 这篇文章 但它似乎只列出了 . load() 或 .get() 但不是 $.post。
<script type="text/javascript">
$(document).ready(function() {
$('#contact form').live('submit', function() {
$.post($(this).attr('action'), $(this).serialize(), function(data) {
$("#contact").replaceWith($(data));
});
return false;
});
});
</script>
i have the following javascript to post a form through ajax without refreshing the screen. Since the post take a little while, i wanted to add a loading image during processing.
I see this article but it seems to only list .load() or .get() but not $.post.
<script type="text/javascript">
$(document).ready(function() {
$('#contact form').live('submit', function() {
$.post($(this).attr('action'), $(this).serialize(), function(data) {
$("#contact").replaceWith($(data));
});
return false;
});
});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需添加一些调用来隐藏/显示您的加载屏幕/div,无论如何:
Just add a few calls to hide/show your load screen/div, whatever:
我将其放入,以便在每个 ajax 调用上显示,无论我有哪一个(我有几个)
只需创建一个带有 #ErrorStatus id 的元素,例如:
现在对于奖金回合,您可以使用此区域放置其他消息发布后,我还包括一个计时器:
像这样使用它:
I put this in so that is shows on every ajax call, no matter which one I have (I have several)
Just create an element with the #ErrorStatus id such as:
Now for the bonus rounds, you can use this area to put other messages up, I also include a timer:
use it like so: