如何获取ajax请求里面的数据
2个回答
展开全部
控制器:
@RequestMapping(value="/info",method=RequestMethod.GET)
@ResponseBody
public Object info(@RequestParam String phone,HttpServletResponse response) throws IOException{
List<User> list=best.FindInfo(phone);
return JSONArray.toJSON(list);
}
.jsp页面:
<script type="text/javascript">
function i(e){
$.ajax({
"url" :"ajaxs",
"type" :"GET",
"data" :"id="+e,
"dataType" :"text",
"success" :callBack
});
}
function callBack (data){
$("#show_table").empty();
var models = eval("("+data+")");
var rows="";
for(var i in models){
rows =rows + "<tr>"+
"<td>"+models[i].ticket_price+"</td>"+
"<td>"+models[i].sell_company+"</td>"+
"</tr>";
}
$("#show_table").append(rows);//添加到table
}
</script>
@RequestMapping(value="/info",method=RequestMethod.GET)
@ResponseBody
public Object info(@RequestParam String phone,HttpServletResponse response) throws IOException{
List<User> list=best.FindInfo(phone);
return JSONArray.toJSON(list);
}
.jsp页面:
<script type="text/javascript">
function i(e){
$.ajax({
"url" :"ajaxs",
"type" :"GET",
"data" :"id="+e,
"dataType" :"text",
"success" :callBack
});
}
function callBack (data){
$("#show_table").empty();
var models = eval("("+data+")");
var rows="";
for(var i in models){
rows =rows + "<tr>"+
"<td>"+models[i].ticket_price+"</td>"+
"<td>"+models[i].sell_company+"</td>"+
"</tr>";
}
$("#show_table").append(rows);//添加到table
}
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询