|
1 | 1 | <?xml version="1.0"?>
|
2 |
| -<entry type="method" name="ajaxStart" return="jQuery"> |
3 |
| - <title>.ajaxStart()</title> |
4 |
| - <signature> |
5 |
| - <added>1.0</added> |
6 |
| - <argument name="handler" type="Function"> |
7 |
| - <desc>The function to be invoked.</desc> |
8 |
| - </argument> |
9 |
| - </signature> |
| 2 | +<entries> |
10 | 3 | <desc>Register a handler to be called when the first Ajax request begins. This is an <a href="/Ajax_Events/">Ajax Event</a>.</desc>
|
11 |
| - <longdesc> |
12 |
| - <p>Whenever an Ajax request is about to be sent, jQuery checks whether there are any other outstanding Ajax requests. If none are in progress, jQuery triggers the <code>ajaxStart</code> event. Any and all handlers that have been registered with the <code>.ajaxStart()</code> method are executed at this time.</p> |
13 |
| - <p>To observe this method in action, set up a basic Ajax load request:</p> |
14 |
| - <pre><code> |
15 |
| -<div class="trigger">Trigger</div> |
16 |
| -<div class="result"></div> |
17 |
| -<div class="log"></div> |
18 |
| - </code></pre> |
19 |
| - <p>Attach the event handler to any element:</p> |
20 |
| - <pre><code> |
21 |
| -$( document ).ajaxStart(function() { |
22 |
| - $( ".log" ).text( "Triggered ajaxStart handler." ); |
23 |
| -}); |
24 |
| - </code></pre> |
25 |
| - <p>Now, make an Ajax request using any jQuery method:</p> |
26 |
| - <pre><code> |
27 |
| -$( ".trigger" ).click(function() { |
28 |
| - $( ".result" ).load( "ajax/test.html" ); |
29 |
| -}); |
30 |
| - </code></pre> |
31 |
| - <p>When the user clicks the element with class <code>trigger</code> and the Ajax request is sent, the log message is displayed.</p> |
32 |
| - </longdesc> |
33 |
| - <note id="global-ajax-event" type="additional" data-title=".ajaxStart()"/> |
34 |
| - <note id="ajax-global-false" type="additional" data-title=".ajaxStart()"/> |
35 |
| - <example> |
36 |
| - <desc>Show a loading message whenever an Ajax request starts (and none is already active).</desc> |
37 |
| - <code><![CDATA[ |
38 |
| -$( document ).ajaxStart(function() { |
39 |
| - $( "#loading" ).show(); |
40 |
| -}); |
41 |
| -]]></code> |
42 |
| - </example> |
43 |
| - <category slug="ajax/global-ajax-event-handlers"/> |
44 |
| - <category slug="version/1.0"/> |
45 |
| -</entry> |
| 4 | + <entry type="method" name="on" return="jQuery"> |
| 5 | + <title>ajaxStart event</title> |
| 6 | + <signature> |
| 7 | + <added>1.7</added> |
| 8 | + <argument name=""ajaxStart"" type="string"> |
| 9 | + <desc>The string <code>"ajaxStart"</code>.</desc> |
| 10 | + </argument> |
| 11 | + <argument name="handler" type="Function"> |
| 12 | + <desc>The function to be invoked.</desc> |
| 13 | + </argument> |
| 14 | + </signature> |
| 15 | + <longdesc> |
| 16 | + <p>Whenever an Ajax request is about to be sent, jQuery checks whether there are any other outstanding Ajax requests. If none are in progress, jQuery triggers the <code>ajaxStart</code> event. Any and all handlers that have been registered with <code>.on( "ajaxStart", ... )</code> are executed at this time.</p> |
| 17 | + <p>To observe this method in action, set up a basic Ajax load request:</p> |
| 18 | + <pre><code> |
| 19 | + <div class="trigger">Trigger</div> |
| 20 | + <div class="result"></div> |
| 21 | + <div class="log"></div> |
| 22 | + </code></pre> |
| 23 | + <p>Attach the event handler to any element:</p> |
| 24 | + <pre><code> |
| 25 | + $( document ).on( "ajaxStart", function() { |
| 26 | + $( ".log" ).text( "Triggered ajaxStart handler." ); |
| 27 | + } ); |
| 28 | + </code></pre> |
| 29 | + <p>Now, make an Ajax request using any jQuery method:</p> |
| 30 | + <pre><code> |
| 31 | + $( ".trigger" ).on( "click", function() { |
| 32 | + $( ".result" ).load( "ajax/test.html" ); |
| 33 | + } ); |
| 34 | + </code></pre> |
| 35 | + <p>When the user clicks the element with class <code>trigger</code> and the Ajax request is sent, the log message is displayed.</p> |
| 36 | + </longdesc> |
| 37 | + <note id="global-ajax-event" type="additional" data-title="ajaxStart"/> |
| 38 | + <note id="ajax-global-false" type="additional" data-title="ajaxStart"/> |
| 39 | + <example> |
| 40 | + <desc>Show a loading message whenever an Ajax request starts (and none is already active).</desc> |
| 41 | + <code><![CDATA[ |
| 42 | + $( document ).on( "ajaxStart", function() { |
| 43 | + $( "#loading" ).show(); |
| 44 | + } ); |
| 45 | + ]]></code> |
| 46 | + </example> |
| 47 | + <category slug="ajax/global-ajax-event-handlers"/> |
| 48 | + <category slug="version/1.0"/> |
| 49 | + </entry> |
| 50 | + |
| 51 | + <entry type="method" name="ajaxStart" return="jQuery" deprecated="3.3"> |
| 52 | + <title>.ajaxStart()</title> |
| 53 | + <signature> |
| 54 | + <added>1.0</added> |
| 55 | + <argument name="handler" type="Function"> |
| 56 | + <desc>The function to be invoked.</desc> |
| 57 | + </argument> |
| 58 | + </signature> |
| 59 | + <longdesc> |
| 60 | + <div class="warning"> |
| 61 | + <p>This API is deprecated.</p> |
| 62 | + <p>Use <a href="#on1"><code>.on( "ajaxStart", handler )</code></a> instead.</p> |
| 63 | + </div> |
| 64 | + </longdesc> |
| 65 | + <category slug="ajax/global-ajax-event-handlers"/> |
| 66 | + <category slug="version/1.0"/> |
| 67 | + <category slug="deprecated/deprecated-3.3"/> |
| 68 | + </entry> |
| 69 | +</entries> |
0 commit comments