Tsallaka zuwa abun ciki
Justice Tech School

Submitting Forms with AJAX

serialize turns form fields into a query string. Send it with $.post and prevent the normal submit.

Example
$('form').on('submit', function (e) {
  e.preventDefault();
  $.post('/save', $(this).serialize()).done(function () {
    $('#msg').text('Saved');
  });
});

Exercise

Turn fields into a string.

$(this).()

Quiz Test

What does serialize do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.