现在的位置: 首页 > 综合 > 正文

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

2014年02月18日 ⁄ 综合 ⁄ 共 554字 ⁄ 字号 评论关闭
  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.     //进行错误处理 

抱歉!评论已关闭.