Arnar, Thanks a million. That was exactly the info I needed. It now works beautifully.
On Jun 15, 3:20 pm, "Arnar Birgisson" <[EMAIL PROTECTED]> wrote: > Hi there, > > On 6/15/07, Yves <[EMAIL PROTECTED]> wrote: > > > I then use DeferredList() to create a list of all the Deferred objects > > and I add a callback. > > > Now my problem is, how do I know from my callback function that the > > result comes from the seventh request I made, or the ninth, etc.? > > The callback to the deferredlist will receive one parameter, an array > with the result of each deferred. Each element of that array is again > a two-element array, the first element being a boolean, true if that > deferred was successful and false otherwise and the second element is > the result of that deferred. To clarify, the result is whatever a > regular callback to that deferred would have received. > > If the index of the deferred doesn't suffice to find the keyword, you > can make sure you receive the keyword like this: > > function combine_key_with_result(key, result) { > return {key: key, result: result}; > > } > > var xhr_deferreds = map(function (key) { > var d = do_your_xhr_call_and_return_deferred(key); > d.addCallback(partial(combine_key_with_result, key)); > return d; > > }, your_keyword_list); > > var dl = new DeferredList(xhr_deferreds); > dl.addCallback(function (results_list) { > forEach(result_list, function (dl_result) { > var success = dl_result[0]; > var key = dl_result[1].key; > var result = dl_result[1].result; > // now do your thing here :) > }) > > }); > > hth, > Arnar --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~----------~----~----~----~------~----~------~--~---