jQuery 表单插件在 FireFox 中响应不佳

标签 jquery forms jquery-plugins

引用插件: 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/

相关文章:

javascript - 无法使用 JS 循环获取选定选项

python - 将 html 表单解析为 python/Flask 中的字典列表

JavaScript 和 Java WebSocket SSL 连接错误

javascript - $。模板返回一个对象而不是函数

javascript - JQuery - 如何 : Duplicate <li> and put it to the end of the <ul>

php - 选择图片中的多个区域

javascript - 清除ajax调用上的图表数据

javascript - jQuery .text 不工作

jquery - ReplaceWith 和 jQuery 可拖放?

javascript - Chrome 浏览器 AJAX 异步问题 : false