jquery ajax
$.ajax({
type: "post",
url: "/×××.do?action=××",
data:"id="+id,
dataType:"html",
success: function(msg){
alert(msg.length);
}
});
java中对应的action 用PrintWriter输出
outPut = "";
if(!outPut.equals("")) {
outPut = "<ul>" + outPut + "</ul>";
response.setContentType("text/html;charset=gbk");
PrintWriter out = response.getWriter();
out.println(outPut);
out.flush();
out.close();
}
return null;
这种写法alert(msg.length)=0
这样写
outPut = "";
if(!outPut.equals("")) {
outPut = "<ul>" + outPut + "</ul>";
}
response.setContentType("text/html;charset=gbk");
PrintWriter out = response.getWriter();
out.println(outPut);
out.flush();
out.close();
return null;
js alert为2
outPut = null:
response.setContentType("text/html;charset=gbk");
PrintWriter out = response.getWriter();
out.println(outPut);
out.flush();
out.close();
return null;
js alert为6
很奇怪的问题,不知道如何解释