Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adding section on referencing bug tracker tickets #2

Closed
wants to merge 2 commits into from

2 participants

@addyosmani

We're currently missing a section in the README on how to reference bug tracker tickets (or what to do when they get addressed here). Hoping this helps.

//cc @kswedberg

@kswedberg
Collaborator

Thanks a lot, Addy! I moved it to the top of the readme. I thought that merging and pushing your commit would automatically close this pull request, but I must have done something wrong. Anyway, all taken care of.

@kswedberg kswedberg closed this
@addyosmani

No worries, Karl! Thanks for reviewing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 46 additions and 0 deletions.
  1. +5 −0 README.md
  2. +41 −0 entries/jQuery.ajax.xml
View
5 README.md
@@ -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.
+
+
View
41 entries/jQuery.ajax.xml
@@ -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>
Something went wrong with that request. Please try again.