(一)java后端
public int ajaxUserRanking(@RequestParam(name = "titleId") Integer titleId){
List<AnswerRecordEntity> thisTitleRanking = answerRecordService.getThisTitleRanking(titleId);
//取出数组中某个用户的排名
int userRanking = 0;
for (int i = 0; i < thisTitleRanking.size(); i++)
{
AnswerRecordEntity auction = thisTitleRanking.get(i);
if (openid.equals(auction.getOpenid()))
{
userRanking = i +1;
break;
}
}
return userRanking;
}
(二)前端
$.ajax({
url:'/XXXXX',
type:'get',
dataType:'json',
async:false,
data:{"titleId":titleId},
success:function(data){
$("#newrangking").html(data);
},
error: function() {
$("#newrangking").html(data);
}
});
标签:int,thisTitleRanking,titleId,传递,ajax,整数,userRanking,data
From: https://www.cnblogs.com/yuguihong/p/16770358.html