Memo: jQuery AJAX Settings Object

The jQuery documentation fails to provide information about exactly what options you can pass to $.ajax.  So here is my quick-and-dirty list:

  • url: string (location.href)
  • global: bool (true) — whether to trigger the global ajax events
  • type: “GET”/”POST” (“GET”)
  • contentType: string (“application/x-www-form-urlencoded”)
  • processData: bool (true)
  • async: bool (true)
  • timeout: int (null)
  • data: object (null)
  • username: string (null)
  • password: string (null)
  • xhr: function – creates the XMLHttpRequest object
  • accepts: object ({ xml: “application/xml, text/xml”, html: “text/html”, script: “text/javascript, application/javascript”, json: “application/json, text/javascript”, text: “text/plain”, _default: “*/*” })
  • dataType: “html”/”text”/”xml”/”json”/”jsonp”/”script”
  • cache: bool (true, unless dataType=script)
  • ifModified: bool (false) — set the If-Modified-Since header (to last request time)
  • beforeSend: function(xhr, settings) (null) — return false to cancel
  • success: function(data, “success”) (null)
  • complete: function(xhr, status) (null) — status is “timeout”/”error”/”notmodified”/”success”/”parsererror”
  • error: function(data, status) (null) — status is “timeout”/”error”/”parsererror

Note to self: format this into a table at some point.

Edit: the documentation has now been fixed, and includes all the options.

Advertisements

Tags: , ,

2 Responses to “Memo: jQuery AJAX Settings Object”

  1. Cipher Says:

    Actually it provides very through documentation of all of the options…
    see here http://docs.jquery.com/Ajax/jQuery.ajax#options

  2. randomguy3 Says:

    Yeah, I noticed a couple of days ago that they’d fixed it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: