多单位版国产化地质资料管理系统
zs
2026-02-04 fe02f176b512a9d6a4e12437d929e04e99bb7567
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
/**
* jQuery扩展 序列化表单为对象
*/
$.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;
}
 
/**
* jQuery扩展 序列化表单为对象(包含空值)
*/
$.fn.serializeObject2 = function() {
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        //和上面的方法对比,主要就是这个判断不一样
        //上面的会把空字符串(即空值)的条件也包含进去,这个不会
        if (o[this.name] != null) {
            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;
}