- $.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;
- };
- var formData = $("#editForm").serializeObject();
var json={
id:"id1",
name:"开心"
};
//添加
json["gender"]="男"
json["age"]=26;
alert(json.age);
//删除
delete json["age"];
alert(json.age);
alert(json.gender);
- $.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;
- };