异步刷新:
controller
@PostMapping("/yibu")
@ResponseBody
public String yibu(String username){
JSONObject jsonObject = new JSONObject();
User user = userService.findByUsername(username);
if (username!=null){
if (user!=null){
jsonObject.put("result","用户存在");
}else {
jsonObject.put("result","用户不存在");
}
}
return jsonObject.toString();
}
页面:
function a1() {
var username = $("#username").val();
// alert(username)
$.ajax({
url:"/yibu",
type: "post",
dataType: "json"