Bootstrap

ajax值上传不过去,Ajax向后台传值失败了呢?

1.问题

后台获取不到Ajax传过来的值

2.贴上相关代码

前台ajax请求;

$.ajax({

url:user/updateHeadImage,

date:{userId:"1",headImage:"Image"},

dataType:'json',

//type:'POST',

success:function(data){

if(data.success){

alert(data.data);

}else{

common.failure(data.data);

}

}.bind(this),

error:function(xhr, status, err){

console.error(url, status, err.toString());

}.bind(this)

})

3.后台java代码:

@RequestMapping(value = "/updateHeadImage")

@ResponseBody

public Result updateHeadImage(Integer userId,String headImage)throws AppException{

memberService.updateHeadImage(userId, headImage);

Member member=new Member();

member.setId(userId);

member.setHeadImage(headImage);

return new Result<>(true,member);

}

4.贴上相关截图

b0dfafaae3157870221a6aafdd8ab792.png

;