把form表单序列化成键值对集合

时间:2015-02-07 00:26:40   收藏:0   阅读:1025

 

window.serializeObj = function(form){

       var o ={ };

       $.each{form.serializeArray(),function(index){

             if(o[this[‘name‘]])

             {

                     o[this[‘name‘]] = o[this[‘name‘]] +","+ this[‘value‘];

             }

             else{

                    o[this[‘name‘]] = this[‘value‘];

             }

             return o;

       }}

 

   //调用

  var obj =serializeObj($("#form1"))          //#form1  表单ID

}

原文:http://www.cnblogs.com/m-r-j/p/4278257.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!