controller:
@RequestMapping("/checkName")
@ResponseBody
public String checkName(String puName){
.............
return "该用户名不存在";
}
ajax:
$.ajax({
type:'post',
url:'checkName',
data:{"puName":$("#puName").val()},
dataType:'text',---------------------------->必须改为json才不显示乱码
success:function(result){
alert(result);
}
}
)'