首页 > 代码库 > JSONP平台对接代码备份
JSONP平台对接代码备份
<script type="text/javascript">
$(function(){
$.ajax({
url:"http://192.168.11.97:8025/battle_summary?player_guid=1000000",
async: false,
dataType:"jsonp",
jsonpCallback:"summary",
success:function(summary){
var counter = 0;
for(var e in summary){
if(counter>4){
break;
}
if(summary[counter].is_win==0){
$("#zhanji2 .content").append(‘<li><img src="http://www.mamicode.com/images/lose.png" /><p class="time">‘+summary[counter].start_time+‘</p><p class="name">‘+summary[counter].map_name+‘</p></li>‘);
}
else{
$("#zhanji2 .content").append(‘<li><img src="http://www.mamicode.com/images/win.png" /><p class="time">‘+summary[counter].start_time+‘</p><p class="name">‘+summary[counter].map_name+‘</p></li>‘);
}
counter++;
}
}
});
$.ajax({
url:"http://192.168.11.97:8025/rank",
async: false,
dataType:"jsonp",
jsonpCallback:"rank",
success:function(rank){
var counter = 0;
for(var e in rank){
if(counter>4){
break;
}
$("#zhanli .zhanli").append(‘<li><img src="http://www.mamicode.com/images/‘+rank[counter].rank+‘.png" class="num" /><img src="http://www.mamicode.com/‘+rank[counter].head+‘"/><p class="name">‘+rank[counter].player_name+‘</p><p class="score">‘+rank[counter].rank_key+‘</p></li>‘);
counter++;
}
}
});
$.ajax({
url:"http://192.168.11.97:8025/dota_info?player_guid=1000000",
async: false,
dataType:"jsonp",
jsonpCallback:"dotainfo",
success:function(dotainfo){
$("#qiang").append(dotainfo.heros[0].qiang);
$("#ying").append(dotainfo.heros[0].ying);
$("#sha").append(dotainfo.heros[0].sha);
$("#fu").append(dotainfo.heros[0].fu);
$("#bu").append(dotainfo.heros[0].bu);
$("#fuzhu").append(dotainfo.heros[0].fuzhu);
$("#zhu").append(dotainfo.heros[0].yuan);
$("#score").append(dotainfo.heros[0].score);
$("#play_count").append(dotainfo.heros[0].play_count);
$("#win_percentage").append(dotainfo.heros[0].win_percentage);
$("#flee_percentage").append(dotainfo.heros[0].flee_percentage);
$("#say_yes").append(dotainfo.say_yes);
console.log(dotainfo.common_heros[0]);
var counter = 0;
for(var e in dotainfo.common_heros){
if(counter>4){
break;
}
$("#common_heros").append(‘<li><img src="http://www.mamicode.com/‘+dotainfo.common_heros[counter]+‘" width="42" height="42" /></li>‘);
counter++;
}
}
});
});
</script>