2011-07-28 54 views
0

我有下面的代碼提交表單,並與服務器的響應代替本身:jQuery的AJAX提交住進去()在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); 
     } 
    }); 
    }); 

它可以在瀏覽器,但它不工作在Firefox中,除非我在開​​始時使用return false而不是event.preventDefault()。爲什麼?

謝謝!

回答

0

你需要在事件經過:

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

我想我可能有問題的錯字,但讓我試,以確保。 –