Answers for "get form values and submit ajax jquery"

15

jquery submit form via ajax

// jQuery ajax form submit example, runs when form is submitted
$("#myFormID").submit(function(e) {
    e.preventDefault(); // prevent actual form submit
    var form = $(this);
    var url = form.attr('action'); //get submit url [replace url here if desired]
    $.ajax({
         type: "POST",
         url: url,
         data: form.serialize(), // serializes form input
         success: function(data){
             console.log(data);
         }
    });
});
Posted by: Guest on July-25-2019

Code answers related to "get form values and submit ajax jquery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language