JQuery刷新包含页面,
参考:http://designgala.com/how-to-refresh-div-using-jquery/
我们的页面一般包含几个页面,每个页面都是一个JSP,当我们用Jquery 向后台提交数据后,根据结果想刷新某一页面如(header.jsp),则可用 Jquery的 Div的load 方法:
$("#divName").load(url, data, callback);url为要刷新的子页面.
注意: Struts2 的Action设置返回类型为Json时其属性值在页面用ognl表达式将无法取到值,如果需要可以将值手动设置到范围对象。
参考代码:
参考:http://designgala.com/how-to-refresh-div-using-jquery/
我们的页面一般包含几个页面,每个页面都是一个JSP,当我们用Jquery 向后台提交数据后,根据结果想刷新某一页面如(header.jsp),则可用 Jquery的 Div的load 方法:
$("#divName").load(url, data, callback);url为要刷新的子页面.
注意: Struts2 的Action设置返回类型为Json时其属性值在页面用ognl表达式将无法取到值,如果需要可以将值手动设置到范围对象。
参考代码:
<%--
Document : user
Created on : Mar 9, 2011, 11:10:39 AM
Author : db2admin
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>user</title>
<script type="text/javascript" src="../jquery-1.4.2.min.js"></script>
</head>
<body>
<%@include file="../include/header.jsp" %>
<input type="button" value="submit" id="button1"/>
</body>
<script type="text/javascript">
$(document).ready(function(){
$("#button1").click(function(){
var header = $("#header").load("../include/header.jsp");
});
});
</script>
</html>