即获取ajax html响应的问题

我有一个表单,提交一些数据并获取html。 这个html用于替换页面上的现有div。

在FF和chrome中,它接收html并呈现罚款。 问题在于,在IE中,它完全“忽略”我的成功函数,并在新页面上呈现接收到的html,这不是预期的function。 我怎么告诉ie不要这样做,只是按照成功function?

我忘了提到这只会在按下“Enter”(有效提交表格)时发生。 使用firefox和chrome,它仍然通过ajax提交表单,但是它通过HTML提交表单,它将我转发给那个html部分响应

$(".toggle-form-submit").parents("form").live("submit", function(){ console.log("WHO"); $.ajax({ dataType: 'js', type: 'POST', url: myForm.attr("action"), data: myForm.serialize(), success: function(html) { alert("WTF"); if(myForm.parents("fieldset").find(".replaceable").length) { updateReplaceableAndClearAndCloseFormWithin(myForm.parents("fieldset"), html); } else { longPanelUpdateReplaceableAndClearAndCloseFormWithin(myForm.parents("fieldset"), html); } if( $(".test-categories-list").length) { initSortableTestCases(); } } }); }); 

你告诉它在点击提交按钮时运行JS ……它不是。

 $(".toggle-form-submit").live('click', 

应该是:

 $("form").live('submit', 

…但是要确保当JS没有运行时,结果仍然有意义。 您不能保证用户(或他们的系统,或连接错误或其他)不会阻止JS。