ajax中post提交form所有元素序列化提交方法.serialize();

  1. $(function() { 
  2.     $('#submit').bind('click'function() { 
  3.  
  4.         var formData = $('#ajaxForm').serialize(); 
  5.         //.serialize() 方法创建以标准 URL 编码表示的文本字符串 
  6.       
  7.         $.ajax({ 
  8.             type : "POST"
  9.             url  : "form.php",  
  10.             cache : false
  11.             data : formData, 
  12.             success : onSuccess, 
  13.             error : onError 
  14.         }); 
  15.         return false
  16.     }); 
  17. }); 
  18.  
  19. function onSuccess(data,status){ 
  20.     data = $.trim(data); //去掉前后空格 
  21.     $('#notification').text(data); 
  22.  
  23. function onError(data,status){ 
  24.     //进行错误处理 
原文地址:https://www.cnblogs.com/y0umer/p/3839180.html