引用插件: http://malsup.com/jquery/form/#getting-started
我最近尝试从旧的 v2.28 升级到 v2.96,但无法升级,因为在尝试使用 FireFox 提交已使用另一个 Ajax 调用加载的表单时,似乎引入了一个新错误。
我有两种表单:一种是在没有 Ajax 调用的情况下加载的,另一种是从服务器加载的。我使用 ajaxForm() 进行绑定(bind):
function bindAjaxResponse() {
// Bind for Ajax POST
var options = {
delegation: true,
//target: '#output1', // target element(s) to be updated with server response
beforeSubmit: showRequest, // pre-submit callback
success: showResponse // post-submit callback
};
$('#my_form').ajaxForm(options);
}
在 Chrome 和 IE 中,代码运行良好,showRequest 和 showResponse 都被调用并填充了正确的参数。对于最新的 FireFox (v10.0.2),仅调用 showRequest,但从不调用 showResponse。 FireBug 清楚地表明根本没有提交。控制台窗口中没有错误消息或警告。我真的不知道什么会引发这种行为差异。
请注意,所有这些代码在旧版本 v2.28 的所有浏览器上都能完美运行
有人吗?
问题交叉发布于 https://forum.jquery.com/topic/jquery-form-plugin-not-responding-well-with-firefox
谢谢
最佳答案
我在使用 jQuery 表单时也遇到了问题,所以我直接调用 $.ajax:
function bindAjaxResponse() {
// Bind for Ajax POST
$('#my_form').submit( function() {
var datastream = $(this).serialize();
console.log('Submitting form');
$.ajax({
type: 'post',
url: $(this).form.attr('action'),
data: datastream,
timeout: 2000,
error: function() {
console.log("Failed to submit");
},
success: function(data) {
console.log('Successfully submitted form');
console.log(data);
}
});
return false;
});
}
关于jQuery 表单插件在 FireFox 中响应不佳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9493576/