在延迟函数之间传递数据 [英] Passing data between deferred functions
本文介绍了在延迟函数之间传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在.done中使用了一些延迟函数,所以,我遇到了类似的事情:
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;
});
但是,尽管formatTime
返回data
,但是html
变量具有askTime
返回的数据.
But although formatTime
returns data
, the html
var has the data returned by askTime
.
我不知道问题出在哪里. formatTime
接收到一个数据变量,该数据变量由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)
它表示未定义data
.
推荐答案
要链接延迟的方法,您需要调用.pipe()
.
To chain deferred methods, you need to invoke .pipe()
.
看看: http://api.jquery.com/deferred.pipe/
这篇关于在延迟函数之间传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文