function appelTeams(team, ligue)
{
$.ajax({
type: 'GET',
url: team,
dataType: 'json',
headers: {"X-AUTH-TOKEN" : 'f6b3ae25342242f8b76a233c4c781686'},
success: function(teams) {
$("#ligue").empty();
$("#teams").empty();
$("#teamSel").empty();
$("#players").empty();
//console.log (teams.teams);
//Ligue SELECTIONE de l'API
$("#ligue").text(ligue);
for (var e =0; e < teams.count; e++)
{
//console.log(e+teams.teams[e].crestUrl);
if (imgServer(teams.teams[e].crestUrl)==2) {
console.log("Holi");
}
//Chaque equipe a ses Joueurs
$("#teams").append("<div class='col-md-3' id = 'team"+e+"' onclick=\"appelPlayers('"+teams.teams[e]._links.players.href+"', '"+teams.teams[e].name+"')\"><img id='img' src='"+teams.teams[e].crestUrl+"'><div><h1>"+teams.teams[e].name+"</h1></div></div>");
//$("#logo").attr('src',teams.teams[e].crestUrl);
}
}
});
}
y quiero llamar a la funcion para verficar si la url de la imagen funciona
function imgServer(img){
var res;
$.ajax({
url: img,
success: function(data) {
res=1
},
error: function() {
res=2;
}
});
return res;
}