好用的js模板

组织form下的 json对象

$.fn.serializeObject = function() {
    var o = {"unique_id":new Date().getTime(),"state":false};
    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;
};

猜你喜欢

转载自www.cnblogs.com/Draymonder/p/10495401.html