var datas = [];
var tb = $('#tb');//query选择器:id为tb的元素
var trs = tb.children();//.children()方法获取tbody的子元素
$.each(trs, function (i, n) {//jquery迭代器,用于循环数组和json i表示索引 n表示当前循环的元素
var irbTypeId = $(n).find("input[name='irbTypeId']").val();
var irbApplyDate = $(n).find("input[name='irbApplyDate']").val();
var irbReviewDate = $(n).find("input[name='irbReviewDate']").val();
var data = {//json对象 {key:value}
"irbTypeId": irbTypeId,
"irbApplyDate": irbApplyDate,
"irbReviewDate": irbReviewDate
};
datas.push(data);//数组的push方法
});
var requestData = JSON.stringify(datas);//将数组对象转换成json字符串
var url = "<s:url value='/srm/ethical/save'/>";
jboxPostJson(url, requestData, function (resp) {
if (resp == '${GlobalConstant.SAVE_SUCCESSED}') {
jboxTip("保存成功!");
window.parent.frames['mainIframe'].window.searchPubProjInfo();
jboxClose();
}
}, null, true);
function jboxPostJson(posturl,postdata,funcOk,funcErr,showResp){
$.ajax({
type : "post",
url : posturl,
//dataType:"json",
contentType:"application/json",
data : postdata,
cache : false,
beforeSend : function(){
jboxStartLoading();
},
success : function(resp) {
jboxEndLoading();
if(showResp==false){
}else{
jboxTip(resp);
}
if(funcOk!=null){
funcOk(resp);
}
},
error : function() {
jboxEndLoading();
jboxTip("操作失败,请刷新页面后重试");
if(funcErr!=null){
funcErr();
}
},
complete : function(){
jboxEndLoading();
}
});
}
后台: @RequestMapping(value = "/save",method={RequestMethod.POST})
@ResponseBody
public String save(@RequestBody ArrayList<SrmIrbApply> srmIrbApplyList ){
}