微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Ajax提交

<script src="<%=request.getcontextpath()%>/creditapp/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
function appExamSubmit(f) {
	var score_list = "";
	var appNo = document.getElementById("app_no").value;
	$("input[type=checkBox]").each(function() {//遍历checkBox,将选择情况连接成String score_list 。
		parm_code = $(this).attr("id");
		score_list += parm_code;
		score_list += ":";
		if ($(this).attr("checked") == true) {
			score_list += "Y";
		} else {
			score_list += "N";
		}
		score_list += "&";
	});
	$.post("ApproveForLoanAction_saveAppExams.action",{//接收的Action
		score_list : score_list,//传递的参数
		appNo : appNo,rdm : Math.random()
	},function(data) {
		if ("success" == $.trim(data)) {
			sAlert("保存成功!");
		} else {
			SAErt("通讯过程中出现错误,请与管理员联系。");
		}
	});
}
</script>

以上为jsp页面代码

下面为Action中的代码

	/*保存指标的确认信息*/
	public void saveAppExams() throws Exception {
		AppExamList appexamlist = new AppExamList();
		HttpServletRequest req = this.getHttpRequest();
		PrintWriter out = null;
		String score_list = req.getParameter("score_list");
		try {
			out = this.getHttpResponse().getWriter();
		} catch (IOException e) {
			e.printstacktrace();
		}
		appexamlist.setApp_no(appNo);
		appexamlist.setTrace_no(appNo);
		appexamlist.setscore_list(score_list);
		try{
			appexamlistbo.insertOrUpdate(appexamlist);
			out.write("success");
		}catch(Exception e){
			out.write("error");
			throw(e);
		}finally{
			out.flush();
			out.close();
		}
	} 


注意事项:

1.别忘了引入jQuery。

2.没有了。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐