You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: entries/jQuery.get.xml
+27-24Lines changed: 27 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@
27
27
});
28
28
</code></pre>
29
29
<p>The <code>success</code> callback function is passed the returned data, which will be an XML root element, text string, JavaScript file, or JSON object, depending on the MIME type of the response. It is also passed the text status of the response. </p>
30
-
<p><strong>As of jQuery 1.5</strong>, the <code>success</code> callback function is also passed a <ahref="http://api.jquery.com/jQuery.get/#jqxhr-object">"jqXHR" object</a> (in <strong>jQuery 1.4</strong>, it was passed the <code>XMLHttpRequest</code> object). However, since JSONP and cross-domain GET requests do not use <abbrtitle="XMLHTTPRequest">XHR</abbr>, in those cases the <code>(j)XHR</code> and <code>textStatus</code> parameters passed to the success callback are undefined.</p>
30
+
<p><strong>As of jQuery 1.5</strong>, the <code>success</code> callback function is also passed a <ahref="/#jqxhr-object">"jqXHR" object</a> (in <strong>jQuery 1.4</strong>, it was passed the <code>XMLHttpRequest</code> object). However, since JSONP and cross-domain GET requests do not use <abbrtitle="XMLHTTPRequest">XHR</abbr>, in those cases the <code>jqXHR</code> and <code>textStatus</code> parameters passed to the success callback are undefined.</p>
31
31
<p>Most implementations will specify a success handler:</p>
<p>This example fetches the requested HTML snippet and inserts it on the page.</p>
38
38
<h4id="jqxhr-object">The jqXHR Object</h4>
39
-
<p><strong>As of jQuery 1.5</strong>, all of jQuery's Ajax methods return a superset of the <code>XMLHTTPRequest</code> object. This jQuery XHR object, or "jqXHR," returned by <code>$.get()</code> implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see <ahref="http://api.jquery.com/category/deferred-object/">Deferred object</a> for more information). For convenience and consistency with the callback names used by <code><ahref="http://api.jquery.com/jQuery.ajax/">$.ajax()</a></code>, it provides <code>.error()</code>, <code>.success()</code>, and <code>.complete()</code> methods. These methods take a function argument that is called when the request terminates, and the function receivesthe same arguments as the correspondingly-named <code>$.ajax()</code> callback.</p>
40
-
<p>The Promise interface in jQuery 1.5 also allows jQuery's Ajax methods, including <code>$.get()</code>, to chain multiple <code>.success()</code>, <code>.complete()</code>, and <code>.error()</code> callbacks on a single request, and even to assign these callbacks after the request may have completed. If the request is already complete, the callback is fired immediately.</p>
39
+
<p><strong>As of jQuery 1.5</strong>, all of jQuery's Ajax methods return a superset of the <code>XMLHTTPRequest</code> object. This jQuery XHR object, or "jqXHR," returned by <code>$.get()</code> implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see <ahref="/category/deferred-object/">Deferred object</a> for more information). The <code>jqXHR.done()</code> (for success), <code>jqXHR.fail() (for error)</code>, and <code>jqXHR.always()</code> (for completion, whether success or error) methods take a function argument that is called when the request terminates. For information about the arguments this function receives, see the <ahref="/jQuery.ajax/#jqXHR">jqXHR Object</a> section of the $.ajax() documentation.</p>
40
+
<p>The Promise interface also allows jQuery's Ajax methods, including <code>$.get()</code>, to chain multiple <code>.done()</code>, <code>.fail()</code>, and <code>.always()</code> callbacks on a single request, and even to assign these callbacks after the request may have completed. If the request is already complete, the callback is fired immediately.</p>
41
41
<pre><code>// Assign handlers immediately after making the request,
42
-
// and remember the jqxhr object for this request
43
-
var jqxhr = $.get("example.php", function() {
44
-
alert("success");
45
-
})
46
-
.success(function() { alert("second success"); })
47
-
.error(function() { alert("error"); })
48
-
.complete(function() { alert("complete"); });
42
+
// and remember the jqxhr object for this request
43
+
var jqxhr = $.get("example.php", function() {
44
+
alert("success");
45
+
})
46
+
.done(function() { alert("second success"); })
47
+
.fail(function() { alert("error"); })
48
+
.always(function() { alert("finished"); });
49
49
50
-
// perform other work here ...
50
+
// perform other work here ...
51
51
52
-
// Set another completion function for the request above
<p>The <code>jqXHR.success()</code>, <code>jqXHR.error()</code>, and <code>jqXHR.complete()</code> callback methods introduced in jQuery 1.5 are <strong>deprecated as of jQuery 1.8</strong>. To prepare your code for their eventual removal, use <code>jqXHR.done()</code>, <code>jqXHR.fail()</code>, and <code>jqXHR.always()</code> instead.</p>
<desc> Gets the test.php page contents, which has been returned in json format (<?php echo json_encode(array("name"=>"John","time"=>"2pm")); ?>), and adds it to the page.</desc>
87
+
<desc> Get the test.php page contents, which has been returned in json format (<?php echo json_encode(array("name"=>"John","time"=>"2pm")); ?>), and add it to the page.</desc>
Copy file name to clipboardExpand all lines: entries/jQuery.post.xml
+35-39Lines changed: 35 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@
28
28
});
29
29
</code></pre>
30
30
<p>The <code>success</code> callback function is passed the returned data, which will be an XML root element or a text string depending on the MIME type of the response. It is also passed the text status of the response.</p>
31
-
<p><strong>As of jQuery 1.5</strong>, the <code>success</code> callback function is also passed a <ahref="http://api.jquery.com/jQuery.get/#jqxhr-object">"jqXHR" object</a> (in <strong>jQuery 1.4</strong>, it was passed the <code>XMLHttpRequest</code> object).</p>
31
+
<p><strong>As of jQuery 1.5</strong>, the <code>success</code> callback function is also passed a <ahref="#jqxhr-object">"jqXHR" object</a> (in <strong>jQuery 1.4</strong>, it was passed the <code>XMLHttpRequest</code> object).</p>
32
32
<p>Most implementations will specify a success handler:</p>
<p>This example fetches the requested HTML snippet and inserts it on the page.</p>
38
38
<p>Pages fetched with <code>POST</code> are never cached, so the <code>cache</code> and <code>ifModified</code> options in <code><ahref="/jQuery.ajaxSetup">jQuery.ajaxSetup()</a></code> have no effect on these requests.</p>
39
39
<h4id="jqxhr-object">The jqXHR Object</h4>
40
-
<p><strong>As of jQuery 1.5</strong>, all of jQuery's Ajax methods return a superset of the <code>XMLHTTPRequest</code> object. This jQuery XHR object, or "jqXHR," returned by <code>$.post()</code> implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see <ahref="http://api.jquery.com/category/deferred-object/">Deferred object</a> for more information). For convenience and consistency with the callback names used by <code><ahref="http://api.jquery.com/jQuery.ajax/">$.ajax()</a></code>, it provides <code>.error()</code>, <code>.success()</code>, and <code>.complete()</code> methods. These methods take a function argument that is called when the request terminates, and the function receivesthe same arguments as the correspondingly-named <code>$.ajax()</code> callback.</p>
41
-
<p>The Promise interface in jQuery 1.5 also allows jQuery's Ajax methods, including <code>$.post()</code>, to chain multiple <code>.success()</code>, <code>.complete()</code>, and <code>.error()</code> callbacks on a single request, and even to assign these callbacks after the request may have completed. If the request is already complete, the callback is fired immediately.</p>
40
+
<p><strong>As of jQuery 1.5</strong>, all of jQuery's Ajax methods return a superset of the <code>XMLHTTPRequest</code> object. This jQuery XHR object, or "jqXHR," returned by <code>$.get()</code> implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see <ahref="/category/deferred-object/">Deferred object</a> for more information). The <code>jqXHR.done()</code> (for success), <code>jqXHR.fail() (for error)</code>, and <code>jqXHR.always()</code> (for completion, whether success or error) methods take a function argument that is called when the request terminates. For information about the arguments this function receives, see the <ahref="/jQuery.ajax/#jqXHR">jqXHR Object</a> section of the $.ajax() documentation.</p>
41
+
<p>The Promise interface also allows jQuery's Ajax methods, including <code>$.get()</code>, to chain multiple <code>.done()</code>, <code>.fail()</code>, and <code>.always()</code> callbacks on a single request, and even to assign these callbacks after the request may have completed. If the request is already complete, the callback is fired immediately.</p>
42
42
<pre><code>// Assign handlers immediately after making the request,
43
-
// and remember the jqxhr object for this request
44
-
var jqxhr = $.post("example.php", function() {
45
-
alert("success");
46
-
})
47
-
.success(function() { alert("second success"); })
48
-
.error(function() { alert("error"); })
49
-
.complete(function() { alert("complete"); });
43
+
// and remember the jqxhr object for this request
44
+
var jqxhr = $.post("example.php", function() {
45
+
alert("success");
46
+
})
47
+
.done(function() { alert("second success"); })
48
+
.fail(function() { alert("error"); })
49
+
.always(function() { alert("finished"); });
50
50
51
-
// perform other work here ...
51
+
// perform other work here ...
52
52
53
-
// Set another completion function for the request above
<p>The <code>jqXHR.success()</code>, <code>jqXHR.error()</code>, and <code>jqXHR.complete()</code> callback methods introduced in jQuery 1.5 are <strong>deprecated as of jQuery 1.8</strong>. To prepare your code for their eventual removal, use <code>jqXHR.done()</code>, <code>jqXHR.fail()</code>, and <code>jqXHR.always()</code> instead.</p>
<desc>Posts to the test.php page and gets contents which has been returned in json format (<?php echo json_encode(array("name"=>"John","time"=>"2pm")); ?>).</desc>
93
+
<desc>Post to the test.php page and get content which has been returned in json format (<?php echo json_encode(array("name"=>"John","time"=>"2pm")); ?>).</desc>
0 commit comments