假设:
1、你的页面在Web-Root下,内容为:
$("#userName").keyup(function(){
$.ajax({
type: "post",
url: "servlet/helloWorldServlet?userName="+$(this).val(),
dataType: "json",
success: function(data){
$("#showMsg").html(data.msg);//修改id为showMsg标签的html
}, error: function(){
alert("请求出错");
}
})
})