1

I'm using some deferred functions with the .done so, I'm having something like that:

askTime(number).done(formatTime).done(function(html){ times += html; }); 

But although formatTime returns data, the html var has the data returned by askTime.

I don't know where if the problem. formatTime receives a data variable which is returned by askTime but if I put:

askTime(number).done(formatTime(data)).done(function(html) 

It says that data isn't defined.

4
  • Try askTime(number).done(function(data) {formatTime(data);}).done(function(html) Commented Dec 2, 2011 at 13:42
  • Inconsistency in Q, But although formatTime returns data & formatTime receives a data variable. Code for askTIme, formatTime will help. Commented Dec 2, 2011 at 13:44
  • @hungryMind both functions works since both were part of the same function I splitted to be able to use them elsewhere. Commented Dec 2, 2011 at 13:48
  • @hungryMind also, your first try (although) seemed logicall to me, didn't work :( Commented Dec 2, 2011 at 13:51

1 Answer 1

2

To chain deferred methods, you need to invoke .pipe().

Have a look: http://api.jquery.com/deferred.pipe/

Sign up to request clarification or add additional context in comments.

4 Comments

I'm having a look but unable to understand correctly. Examples given are a bit hard or unclear (for me at least)
@AntonioLaguna Just try ".pipe()" instead of the first ".done()" in your code.
I picked up the final code from here stackoverflow.com/questions/5921283/… and works and seems to understandable to me but this is not exactly what comes in the docs. Could you give me more light please?
Thanks again @jAndy you seem to be a master of the deferred!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.