//将Form 表单转换为Json字符串
        $.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 || '';
                }
            });
            //o 为Json对象
            return o;
        };

方法调用: $('#formSchool').serializeObject()

posted on 2018-04-18 18:28  高兴happy  阅读(143)  评论(0编辑  收藏  举报