SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $('.js-submit').on('click',function(e){
  2.     e.preventDefault();
  3.     var thisForm = $(this).closest('.contentForm');
  4.     var formAction = thisForm.attr('data-action');
  5.     var formMethod = thisForm.attr('data-method');
  6.  
  7.     var data = thisForm.find("input,select,textarea").serialize()
  8.  
  9.     $.ajax({
  10.         type: formMethod,
  11.         url: formAction,
  12.         data: data,
  13.         success: function() {
  14.             console.log('success!'); // or not!
  15.         },
  16.         error:function (xhr, ajaxOptions, thrownError){
  17.             console.log(xhr.status); // 0
  18.             console.log(thrownError); // empty
  19.         }
  20.     });
  21. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top