Advertisement
tok124

AJAX Form

Nov 27th, 2017
113
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function() {
  2.     $('.myForm').submit(function (event) {
  3.       var data = $(this);
  4.       $.ajax({
  5.         type: data.attr('method'),
  6.         url: data.attr('action'),
  7.         data: data.serialize(),
  8.         success: function (data) {
  9.           $('.output').html(data);
  10.           $('.myForm input:NOT([type=submit])').val('');
  11.         }
  12.       });
  13.       event.preventDefault();
  14.     });
  15. });
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement