ajax 图像未显示在表单提交上,但在 Firefox 中显示正常
这是我用来在表单提交上显示 ajax 图像的代码:
$(document).ready(function() {
$('#form_id').bind('submit', function() {
$('#img-div').show();
});
$('#form_id').submit('submit', function(event) {
event.preventDefault();
..........................
......................
});
});
这在一个页面中工作正常,但在不同页面中则不然。 在 Firefox 上,两个页面都工作正常。
上面的代码可能有什么问题...
编辑:
这只发生在一种特定情况下。 AJAX 调用使页面无响应并且图像不显示,如果我显示加载图像,它会在 ajax 调用期间停止动画。我尝试使用 jQuery UI 对话框,结果仍然相同,但在 Firefox 上工作正常。 。
Here is the code am using to show an ajax image on form submit:
$(document).ready(function() {
$('#form_id').bind('submit', function() {
$('#img-div').show();
});
$('#form_id').submit('submit', function(event) {
event.preventDefault();
..........................
......................
});
});
This works fine in one page, and doesn't in a different page.
Where as on Firefox both pages work fine.
What could be wrong in the above code...
EDIT:
This only happens in one particular case. The AJAX call makes the page unresponsive and the image does not show, if I show a loading image, it stops animating for the duration of ajax call., I tried using jQuery UI dialog, still same result, works fine on Firefox though...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的。
.bind('submit',function(){})
类似于.submit(function(){})
。并且.submit()
函数不需要“submit”作为参数。我认为您想要的代码是这样的:
尝试一下并让我知道。我怀疑 Firefox 可能对你损坏的代码更宽容,而其他浏览器只是在遇到它时就崩溃了。
OK.
.bind('submit',function(){})
is analogous to.submit(function(){})
. And the.submit()
function doesn't need 'submit' as an argument.I think the code you want is this:
Try that and let me know. I suspect Firefox may have been more tolerant to your broken code, whereas other browsers just broke when it hit it.