Answers for "get form data on submit ajax"

1

ajax submit form data

$(function() {
  $('form.my_form').submit(function(event) {
    event.preventDefault(); // Prevent the form from submitting via the browser
    var form = $(this);
    $.ajax({
      type: form.attr('method'),
      url: form.attr('action'),
      data: form.serialize()
    }).done(function(data) {
      // Optionally alert the user of success here...
    }).fail(function(data) {
      // Optionally alert the user of an error here...
    });
  });
});
Posted by: Guest on December-22-2020
0

ajax get form data

var form = // Select your form here;
var fmData = new FormData();
form.append('name',fmData);
$.ajax({
  url:'URL',
  type:'POST',
  data:fmData,
  success:function(){},
  error:(er){}
})
Posted by: Guest on May-23-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language