jQuery ajax提交内部live()不在Firefox中工作

我有以下代码提交表单并将其自身替换为服务器的响应:

$("form.replaceWithResponse").live("submit", function() { event.preventDefault(); // not preventing default form submission in Firefox var $this = $(this); $.ajax({ data: $this.serialize(), dataType: "html", type: $this.attr("method"), url: $this.attr("action"), success: function(html) { $this.replaceWith(html); } }); }); 

它适用于Chrome,但它在Firefox中不起作用,除非我在结尾处使用return false而不是在开头使用event.preventDefault() 。 为什么?

谢谢!

你需要传递这个事件:

 $("form.replaceWithResponse").live("submit", function(event) { event.preventDefault();