Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $('form.ajax').on('submit', function() {
  2.     var current = $(this),
  3.         url = current.attr('action'),
  4.         type    = current.attr('method'),
  5.         data    = [];
  6.     current.find('[name]').each(function(index, value) {
  7.         var current = $(this),
  8.             name    = current.attr('name'),
  9.             value   = current.val();
  10.            
  11.             data[name] = value;
  12.     });
  13. $.ajax({
  14.         url: url,
  15.         type: type,
  16.         data: data,
  17.         success: function(response) {
  18.             console.log(response);
  19.         }
  20.     });
  21.     return false;  
  22. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement