Skip to content

Commit 6eece50

Browse files
David BazileAurelioDeRosa
David Bazile
authored andcommitted
jQuery.ajax: Added example for the accepts property
Closes jquerygh-811
1 parent fc260f6 commit 6eece50

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

entries/jQuery.ajax.xml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,27 @@
1616
<argument name="settings" type="PlainObject" optional="true">
1717
<desc>A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with <a href="/jQuery.ajaxSetup/">$.ajaxSetup()</a>.</desc>
1818
<property default="depends on DataType" name="accepts" type="PlainObject">
19-
<desc>The content type sent in the request header that tells the server what kind of response it will accept in return.</desc>
19+
<desc>A set of key/value pairs that map a given <code>dataType</code> to its MIME type, which gets sent in the <code>Accept</code> request header. This header tells the server what kind of response it will accept in return. For example, the following defines a custom type <code>mycustomtype</code> to be sent with the request:
20+
<pre><code>
21+
$.ajax({
22+
accepts: {
23+
mycustomtype: 'application/x-some-custom-type'
24+
},
25+
26+
// Instructions for how to deserialize a `mycustomtype`
27+
converters: {
28+
'text mycustomtype': function(result) {
29+
// Do Stuff
30+
return newresult;
31+
}
32+
},
33+
34+
// Expect a `mycustomtype` back from server
35+
dataType: 'mycustomtype'
36+
});
37+
</code></pre>
38+
<strong>Note:</strong> You will need to specify a complementary entry for this type in <code>converters</code> for this to work properly.
39+
</desc>
2040
</property>
2141
<property default="true" name="async" type="Boolean">
2242
<desc>By default, all requests are sent asynchronously (i.e. this is set to <code>true</code> by default). If you need synchronous requests, set this option to <code>false</code>. Cross-domain requests and <code>dataType: "jsonp"</code> requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. <strong>As of jQuery 1.8, the use of <code>async: false</code> with jqXHR (<code>$.Deferred</code>) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as <code>jqXHR.done()</code> or the deprecated <code>jqXHR.success()</code>.</strong></desc>

0 commit comments

Comments
 (0)