http://blog.csdn.net/zhang_j_h/article/details/44563167
存入:
function GetInputData(id, cmd) {
var postdata = "{ "action":"" + cmd + "",";
$("#" + id + " input[type!='checkbox']").each(function () {
postdata += """ + $(this).attr("name") + "":"" + $(this).val() + "",";
});
$("#" + id + " input[type='checkbox']").each(function () {
postdata += """ + $(this).attr("name") + "":"" + this.checked + "",";
});
$("#" + id + " select").each(function () {
postdata += """ + $(this).attr("name") + "":"" + this.value + "",";
});
$("#" + id + " textarea").each(function () {
postdata += """ + $(this).attr("name") + "":"" + this.value.replace(/
|
/g, "<br>") + "",";
});
postdata = postdata.substr(0, postdata.length - 1);
postdata += "}";
return eval("(" + postdata + ")");
}
提交:var json = GetInputData("AthleteViolationInfoForm", "submit");
读取:
$("#ipt_actionresult").val(dataObj.ipt_actionresult.replace(/<br>/g, ' '));//读取数据时把数据匹配正则替换正确的回车符号(符合的编码,用于正确显示)
alue.replace(/<br>/g, "");//替换换行为空