Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Form Plugin not responding well with FireFox

Referring to the plugin: http://malsup.com/jquery/form/#getting-started

I've recently tried to upgrade from old v2.28 to v2.96 but cannot as there appears to be a new bug introduced when trying to use FireFox to submit a form that has been loaded using another Ajax call.

I have two kinds of forms: ones that I load without an Ajax call and other that I load from the server. I use ajaxForm() for the binding:

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);   
}

In both Chrome and IE, the code works well and both showRequest and showResponse are called and filled with proper parameters. With latest FireFox (v10.0.2) only showRequest is called but showResponse is never called. FireBug clearly shows that no submission is done at all. There are no error messages nor warnings in the console window. I really have no idea what could trigger such a difference in behavior.

Please mind that all this code worked perfectly on all browser in the older version v2.28

Anyone?

Question cross-posted on https://forum.jquery.com/topic/jquery-form-plugin-not-responding-well-with-firefox

Thanks

like image 811
Collector Avatar asked Feb 29 '12 04:02

Collector


2 Answers

I was having problems with jQuery forms as well, so I just call $.ajax directly:

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;
    });
}
like image 50
ub3rst4r Avatar answered Sep 18 '22 13:09

ub3rst4r


Seems there was a bug in v2.96 and as I now upgraded to v3.02 it is solved.

like image 35
Collector Avatar answered Sep 22 '22 13:09

Collector