Form submit without refresh using jquery/ajax if page have more than one form

前端 未结 4 882
抹茶落季
抹茶落季 2020-12-11 10:14

Hi all I know that its very easy to submit a form without refreshing if there is only one form on the page but what about if there are more than one form on the page. Im usi

4条回答
  •  旧巷少年郎
    2020-12-11 10:34

    Just customize your function and add params like formid to get form data within the function to pass processForm("id of the form");

    function processForm(formId) { 
        //your validation code
        $.ajax( {
                type: 'POST',
                url: form_process.php,
                data: $("#"+formId).serialize(), 
                success: function(data) {
                    $('#message').html(data);
                }
            } );
        }
    
    

提交回复
热议问题