下面是将表单数据转换成json对象
其中的 o[this.name] 老不理解是什么意思?求大神指教!
var 0={};表示声明一个json对象
o[this.name]是什么意思啊?这是什么写法啊?
// 将表单数据转换成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;
};