Loading

获取Form表单数据转化成JSON对象

$.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;  
}

获取表单数据

$('form').serializeObject();
posted @ 2017-10-25 10:16  王召波  阅读(8451)  评论(0编辑  收藏  举报