码迷,mamicode.com
首页 > 其他好文 > 详细

如何序列化表单数据

时间:2015-06-04 15:40:27      阅读:103      评论:0      收藏:0      [点我收藏+]

标签:

    $.fn.serializeObject = function()    
    {    
       var o = {};    
       var a = this.serializeArray();    
       $.each(a, function() {    
           if (o[this.name]) {    
               if (!o[this.name].push) {    
                   o[this.name] = [o[this.name]];    
               }    
               o[this.name].push(this.value || ‘‘);    
           } else {    
               o[this.name] = this.value || ‘‘;    
           }    
       });    
       return o;    
    };

调用该函数如下:

dataArray = $("form").serializeObject();

 

如何序列化表单数据

标签:

原文地址:http://www.cnblogs.com/keliyxyz/p/4551832.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!