File: index.html

package info (click to toggle)
jqapi 1.7%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 3,288 kB
  • sloc: javascript: 632; makefile: 12
file content (66 lines) | stat: -rw-r--r-- 3,908 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang='en'><head><meta http-equiv='content-type' content='text/html; charset=UTF-8' /></head><body>
<div class="entry-content">
        <div class="entry-title roundTop">
          
          <h1 class="jq-clearfix">deferred.then()</h1>
          <div class="entry-meta jq-clearfix">
                        Categories:
            <span class="category"><a href="http://api.jquery.com/category/deferred-object/" title="View all posts in Deferred Object">Deferred Object</a></span>
  

          </div>

</div>
<div id="deferred-then1" class="entry method">
<h2 class="jq-clearfix roundTop section-title">
<span class="name">deferred.then( doneCallbacks, failCallbacks )</span> <span class="returns">Returns: <a class="return" href="http://api.jquery.com/Types/#Deferred">Deferred</a></span>
</h2>
<div class="jq-box roundBottom entry-details">
<p class="desc"><strong>Description: </strong> Add handlers to be called when the Deferred object is resolved or rejected. </p>
<ul class="signatures">
<li class="signature" id="deferred-then-doneCallbacks-failCallbacks">
<h4 class="name">
<span class="versionAdded">version added: <a href="/category/version/1.5/">1.5</a></span>deferred.then( doneCallbacks, failCallbacks )</h4>
<p class="arguement"><strong>doneCallbacks</strong>
             A function, or array of functions, called when the Deferred is resolved.
           </p>
<p class="arguement"><strong>failCallbacks</strong>
             A function, or array of functions, called when the Deferred is rejected.
           </p>
</li>
<li class="signature" id="deferred-then-doneCallbacks-failCallbacks-progressCallbacks">
<h4 class="name">
<span class="versionAdded">version added: <a href="/category/version/1.7/">1.7</a></span>deferred.then( doneCallbacks, failCallbacks [, progressCallbacks] )</h4>
<p class="arguement"><strong>doneCallbacks</strong>
             A function, or array of functions, called when the Deferred is resolved.
           </p>
<p class="arguement"><strong>failCallbacks</strong>
             A function, or array of functions, called when the Deferred is rejected.
           </p>
<p class="arguement"><strong>progressCallbacks</strong>
             A function, or array of functions, called when the Deferred notifies progress.
           </p>
</li>
</ul>
<div class="longdesc">
<p>All three arguments (including progressCallbacks, as of jQuery 1.7) can be either a single function or an array of functions. The arguments can also be <code>null</code> if no callback of that type is desired. Alternatively, use <code>.done()</code>, <code>.fail()</code> or <code>.progress()</code> to set only one type of callback. </p>
<p>When the Deferred is resolved, the doneCallbacks are called. If the Deferred is instead rejected, the failCallbacks are called. As of jQuery 1.7, the <code>deferred.notify()</code> or <code>deferred.notifyWith()</code> methods can be called to invoke the progressCallbacks as many times as desired before the Deferred is resolved or rejected.</p>
<p>Callbacks are executed in the order they were added. Since <code>deferred.then</code> returns the deferred object, other methods of the deferred object can be chained to this one, including additional <code>.then()</code> methods. For more information, see the documentation for <a href="http://api.jquery.com/category/deferred-object/">Deferred object</a>.</p>
</div>
<h3>Example:</h3>
<div class="entry-examples" id="entry-examples"><div id="example-0">
<h4><span class="desc">Since the jQuery.get method returns a jqXHR object, which is derived from a Deferred object, we can attach handlers using the .then method.</span></h4>
<pre class="prettyprint"><code class="example">
$.get("test.php").then(
    function(){ alert("$.get succeeded"); },
    function(){ alert("$.get failed!"); }
);
</code></pre>
</div></div>
</div>
</div>

        </div>

</body></html>