Sometimes when the user triggers the same event more than once, the same Ajax call is made multiple times. Its pretty straight forward to setup a simple object to keep track of identical calls and abort the oldest ones, but how can I deal with this when there are chains of calls made?
有时,当用户多次触发同一事件时,会多次进行相同的Ajax调用。它非常直接设置一个简单的对象来跟踪相同的调用并中止最旧的调用,但是当有调用链时我怎么能处理这个?
What do I mean with chains: Lets say user clicks a button and that triggers ajax_A(...). At some later point ajax_B(...) is also executed. At this point the user clicks the same button again which invokes the same chain again.
我对链是什么意思:假设用户点击一个按钮并触发ajax_A(...)。在稍后的某个时刻,ajax_B(...)也会被执行。此时,用户再次单击相同的按钮,再次调用同一个链。
Is there a practical way of aborting the whole chain (both ajax_A(...) and ajax_B(...))?
是否存在中止整个链的实用方法(ajax_A(...)和ajax_B(...))?
Our current solution is quite obtrusive for those sections where we make an ajax call that is part of a chain.
我们当前的解决方案对于我们进行链接的ajax调用的那些部分非常突兀。
1 个解决方案
#1
1
You might want to have a look at the new jQuery 1.5 deferreds: http://www.erichynds.com/jquery/using-deferreds-in-jquery/
您可能希望查看新的jQuery 1.5延迟:http://www.erichynds.com/jquery/using-deferreds-in-jquery/
#1
1
You might want to have a look at the new jQuery 1.5 deferreds: http://www.erichynds.com/jquery/using-deferreds-in-jquery/
您可能希望查看新的jQuery 1.5延迟:http://www.erichynds.com/jquery/using-deferreds-in-jquery/