rrylee
10/16/2015 - 3:54 PM

jQuery ajax最佳实践

jQuery ajax最佳实践

(function($) {

  $('form').on('submit', function(e) {
    e.preventDefault();
    
    var $this = $(this);
    
    $.ajax({
      url: $this.attr('action'),
      method: $this.attr('method'),
      data: $this.serializeArray(),
      success: function(response) {
        console.log(response);
      }
    })
  });

})(jQuery)