<script type="text/javascript" src="js/jquery.min.js"></script>
// I have jquery.js under js directory in my webapp
<script type="text/javascript">
var url = "my.jsp";
$(function(){
$.ajax({
url : url, // Pass you Servlet/ JSP Url
dataType : 'html',
success : function(response) {
alert('Success');
$('#output').html(response);
},
error : function(request, textStatus, errorThrown) {
alert(request.status + ', Error: ' + request.statusText);
// perform tasks for error
}
});
});
</script>
JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%
out.println("<h1>Hello World</h1>"); // Write html values here
%>
Your HTML
....
<div id="output"></div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…