Javascript代码:
$.ajax({
url:'/htmltest',
type:'get',
dataType:'xml',
timeout:1000,
error:function() {
alert("request error!");
},
success:function(da
ta) {
alert(da
ta);
$(da
ta).find("div").each(function() {
var text = $(this).text();
alert(text);
});
}
});
Java代码:
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
httpServletResponse.setContentType("text/xml;charset=utf-8");
httpServletResponse.setHeader("Cache-Control","no-cache");
PrintWriter out = httpServletResponse.getWriter();
out.println("
test dom tree
");