Form not submitting with AJAX

后端 未结 6 1645
执笔经年
执笔经年 2021-01-17 00:29

=====UPDATE AGAIN==== (if anyone cares!) the solution I posted before stopped working for whatever reason. I included a beforeSend in my ajax request and pasted the portion

6条回答
  •  萌比男神i
    2021-01-17 01:25

    Try coding in the following format. The logic uses an if/else statement to make the ajax call.

    $('form').on('submit', function(e) {
        //If form could not be validated
        if(!validateForm(this)){
           //prevent the form form submitting
            alert("Your form is not valid for submission!");
            e.preventDefault();  
        }
        //else 
        else{
            //form input is valid
            //make the ajax call
            $.ajax({
                type: "post",
                url: "client_config_send2.php",
                data: $(this).serialize(),
                done:  function(data){
                    alert("Thank you, we will get back to you shortly");
                }
               });
           }
        });
     });
    

提交回复
热议问题