Hey, Have you thought about setting a key,value pair in your JSON being returned corrasponding too the url=" + escape($ (this).attr("id")" that your passing in, then on the callback just use $("#"+myJson[:id]) or something like that? just a thought.
GreatS wrote: > > Currently I go through a number of elements using the each function > and for each element I do an ajax call, the result of each ajax call > should then replace the content of the corresponding element. When I > started working on it, it sounded ridiculously easy, however I am > unable to identify which element corresponds to which ajax response > function, due to the fact that the ajax call is asynchronous to the > script. Here is the main part of the script: > $(".shorten").each(function(){ > element = this; > $.getJSON("http://safe.mn/api/?format=jsonp&url=" + escape($ > (this).attr("id")) + "&callback=?", > function(data){ > // element will be the last element in the each loop > } > ); > }); > I have no clue at all anymore on how to solve it, so a pointer in the > right direction would be more then appreciated. Essentially all I need > is to pass a variable from outside the ajax call - at the point the > ajax call is launched - into the response function. > Thanks in advance, > > -- View this message in context: http://old.nabble.com/Ajax-call-for-each-element-tp26361606s27240p26362955.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.