Fork me on GitHub
              $.fn.serializeJson = 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;
			};

  在javascript中添加该方法

使用该方法就可以进行转换

    var jso = $("#表单名(form的id属性)").serializeJson();

json对象转换String

    JSON.stringify(lf)

posted on 2017-12-24 13:11  TopTime  阅读(1833)  评论(1编辑  收藏  举报