您的位置:首页 > Web前端 > JQuery

jquery form表单序列化成json格式

2015-09-07 15:59 447 查看
 $.fn.serializeObject = function()

{

    var o = {};

    var a = this.serializeArray();

    $.each(a, function() {

        if (o[this.name] !== undefined) {

            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;

};

JSON.stringify($("#form").serializeObject()); 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jQuery