Je mets à jour certains div comme suit:jQuery: Comment transmettre une valeur dans un appel Ajax?
for(var i = 0; i < data.length; i++) {
var query = base_url + data[i];
$.ajax({
url: query,
type: 'GET',
dataType: 'jsonp',
timeout: 2000,
error: function() { self.html("Network Error"); },
success: function(json) {
$("#li" + i).html("<img src='" + json.result.list[0].url + "' />")
}
});
}
La valeur de i ne fonctionne pas dans l'appel ajax. J'essaie de passer la valeur de i pour qu'il puisse attacher l'élément à la div appropriée. Est-ce que quelqu'un peut m'aider?
votre ' Reigel
Just curious, stepping back a level, is firing off 'n' ajax requests the only way to do what you're after? Can this not be done as a batch in one round-trip? This would be a much better and more responsive user experience. –
@Reigel: Fixed it thanks. @Nick: Sorry but could you explain that a little more? I am open to a better approach. – Legend