我想做这样的事情,但是这个看起来像是在无限次地徘徊.
$("form").live("submit", function() {
if($(this).attr('action') != "ajax"){
$(this).submit();
return true; // even i do this!! but form is NOT submited!!
}
else { /* doing the ajax stuff! */ }
});
Run Code Online (Sandbox Code Playgroud)
在Chrome和Firefox中,一段时间后表单被提交,类似于10秒,在IE中它崩溃了!
我知道当我说form.submit意味着我提交这个并且一次又一次地调用函数,我怎么能避免这个?
Nic*_*ver 11
通过.submit()再次fring ,返回到.live()处理程序,你导致一个无限循环,而你想在form.submit()这里调用本机方法,如下所示:
$("form").live("submit", function() {
if(this.action != "ajax") {
this.submit();
}
else { /* doing the ajax stuff! */ }
});
Run Code Online (Sandbox Code Playgroud)
也是.action本机DOM属性,您可以通过这种方式访问它...这里不需要jQuery开销.
| 归档时间: |
|
| 查看次数: |
15698 次 |
| 最近记录: |