Skip to content

Adding section on referencing bug tracker tickets #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ Code in the API documentation should follow the [jQuery Core Style Guide](http:/
* Authoritive
* Tactful

## Referencing Bug Tracker Tickets

Pull requests suggesting changes to documentation that were requested or recommended via the [jQuery Bug Tracker](http://bugs.jquery.com) should include a link back to the relevant bug ticket. Should a `#needsdocs` item be addressed here, the tag should be removed from the bug ticket to ensure the backlog is kept up to date.


41 changes: 41 additions & 0 deletions entries/jQuery.ajax.xml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,47 @@ jQuery.ajaxSettings.xhr = function () {
};
</pre>


<h4>Using Converters</h4>

<p><code>$.ajax()</code> converters support mapping data types to other data types. If however we want to map a custom data type to a known type (e.g <code>json</code>), a correspondance must be added between the response Content-Type and actual data type using the <code>contents</code> option:</p>

<pre>
$.ajaxSetup({
contents: {
mycustomtype: /mycustomtype/
},
converters: {
"mycustomtype json": function ( result ) {
// do stuff
return newresult;
}
}
});
</pre>

<p>The reason we use another map for this is because the response Content-Types and data types never have a strict one-to-one correspondance (hence the regular expression).</p>

<p>If converting from a supported type (e.g <code>text</code>, <code>json</code>) to a custom data type and back again is desired, another pass-through converter can be used on top of this:</p>

<pre>
$.ajaxSetup({
contents: {
mycustomtype: /mycustomtype/
},
converters: {
"text mycustomtype": true,
"mycustomtype json": function ( result ) {
// do stuff
return newresult;
}
}
});
</pre>

<p>The above now allows passing from <code>text</code> to <code>mycustomtype</code> and then <code>mycustomtype</code> to <code>json</code>.</p>


<h4>Extending Ajax</h4>
<p><strong>As of jQuery 1.5</strong>, jQuery's Ajax implementation includes prefilters, converters, and transports that allow you to extend Ajax with a great deal of flexibility. For more information about these advanced features, see the <a href="http://api.jquery.com/extending-ajax/">Extending Ajax</a> page.</p>
</longdesc>
Expand Down