jquery ajax 局部刷新小案例

代码如下:

<html>
<head>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript"> 
function getOtherMessage(){ 
$.ajax({ 
type:"post", 
url:"${pageContext.request.contextPath}/getOtherMessage.do", 
success:function(msg){ 
$("#view").html(msg); 
}, 
error:function(){ 
alert("wrong"); 
} 
}); 
} 
</script>
</head>
<body>
<input type="button" value="修改" onclick="getOtherMessage();" />
<div id="view">
456
</div>
</body>
</html>

相关推荐