1
Quelle est la meilleure façon d'obtenir une réponse json dans un tableau que je peux utiliser dans l'exemple ci-dessous? C'est ma fonction qui appelle déclenche l'appel ajax:Réponse json dans un tableau
function getMaps(){
mapID = "aus";
mapImg = 'map_australia.jpg';
$.ajax({
type: "GET",
url: "getMap.asp",
data: "id=" + mapID,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
//not sure what to do here
}
});
return //not sure what to return here
// it should resemble: return {id: 'aus', image: '/resources/images/maps/map_australia.jpg', data: '', maps: []};
};
Pour des fins de test getMap.asp renvoie le follwoing:
{'j':[{'id':'aus','image':'/images/maps/map_detail.jpg','data':'','maps':[]}]}
Vous ne cherchez pas à retourner un tableau, mais un objet. – BoltClock