Skip to content

Commit cc962b2

Browse files
AurelioDeRosaarthurvr
authored andcommitted
jQuery.ajax: add method option and update examples to use it
Fixes gh-609 Closes gh-671
1 parent 6ce2c3a commit cc962b2

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

entries/jQuery.ajax.xml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<desc>A string containing the URL to which the request is sent.</desc>
99
</argument>
1010
<argument name="settings" type="PlainObject" optional="true">
11-
<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>. See <a href="#jQuery-ajax-settings">jQuery.ajax( settings )</a> below for a complete list of all settings. </desc>
11+
<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>. See <a href="#jQuery-ajax-settings">jQuery.ajax( settings )</a> below for a complete list of all settings.</desc>
1212
</argument>
1313
</signature>
1414
<signature>
@@ -82,7 +82,7 @@ $.ajax({
8282
<argument name="jqXHR" type="jqXHR"/>
8383
<argument name="textStatus" type="String"/>
8484
<argument name="errorThrown" type="String"/>
85-
<desc>A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides <code>null</code>) are <code>"timeout"</code>, <code>"error"</code>, <code>"abort"</code>, and <code>"parsererror"</code>. When an HTTP error occurs, <code>errorThrown</code> receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." <strong>As of jQuery 1.5</strong>, the <code>error</code> setting can accept an array of functions. Each function will be called in turn. <strong>Note:</strong> <em>This handler is not called for cross-domain script and cross-domain JSONP requests.</em> This is an <a href="/Ajax_Events/">Ajax Event</a>. </desc>
85+
<desc>A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides <code>null</code>) are <code>"timeout"</code>, <code>"error"</code>, <code>"abort"</code>, and <code>"parsererror"</code>. When an HTTP error occurs, <code>errorThrown</code> receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." <strong>As of jQuery 1.5</strong>, the <code>error</code> setting can accept an array of functions. Each function will be called in turn. <strong>Note:</strong> <em>This handler is not called for cross-domain script and cross-domain JSONP requests.</em> This is an <a href="/Ajax_Events/">Ajax Event</a>.</desc>
8686
</property>
8787
<property default="true" name="global" type="Boolean">
8888
<desc>Whether to trigger global Ajax event handlers for this request. The default is <code>true</code>. Set to <code>false</code> to prevent the global handlers like <code>ajaxStart</code> or <code>ajaxStop</code> from being triggered. This can be used to control various <a href="/Ajax_Events/">Ajax Events</a>.</desc>
@@ -94,15 +94,18 @@ $.ajax({
9494
<desc>Allow the request to be successful only if the response has changed since the last request. This is done by checking the Last-Modified header. Default value is <code>false</code>, ignoring the header. In jQuery 1.4 this technique also checks the 'etag' specified by the server to catch unmodified data.</desc>
9595
</property>
9696
<property default="depends on current location protocol" name="isLocal" type="Boolean" added="1.5.1">
97-
<desc>Allow the current environment to be recognized as "local," (e.g. the filesystem), even if jQuery does not recognize it as such by default. The following protocols are currently recognized as local: <code>file</code>, <code>*-extension</code>, and <code>widget</code>. If the <code>isLocal</code> setting needs modification, it is recommended to do so once in the <code>$.ajaxSetup()</code> method. </desc>
97+
<desc>Allow the current environment to be recognized as "local," (e.g. the filesystem), even if jQuery does not recognize it as such by default. The following protocols are currently recognized as local: <code>file</code>, <code>*-extension</code>, and <code>widget</code>. If the <code>isLocal</code> setting needs modification, it is recommended to do so once in the <code>$.ajaxSetup()</code> method.</desc>
9898
</property>
9999
<property name="jsonp" type="String">
100100
<desc>Override the callback function name in a JSONP request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url. So <code>{jsonp:'onJSONPLoad'}</code> would result in <code>'onJSONPLoad=?'</code> passed to the server. <strong>As of jQuery 1.5</strong>, setting the <code>jsonp</code> option to <code>false</code> prevents jQuery from adding the "?callback" string to the URL or attempting to use "=?" for transformation. In this case, you should also explicitly set the <code>jsonpCallback</code> setting. For example, <code>{ jsonp: false, jsonpCallback: "callbackName" }</code></desc>
101101
</property>
102102
<property name="jsonpCallback">
103103
<type name="String"/>
104104
<type name="Function"/>
105-
<desc>Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. <strong>As of jQuery 1.5</strong>, you can also use a function for this setting, in which case the value of <code>jsonpCallback</code> is set to the return value of that function. </desc>
105+
<desc>Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. <strong>As of jQuery 1.5</strong>, you can also use a function for this setting, in which case the value of <code>jsonpCallback</code> is set to the return value of that function.</desc>
106+
</property>
107+
<property default="'GET'" name="method" type="String" added="1.9.0">
108+
<desc>The HTTP method to use for the request (e.g. <code>"POST"</code>, <code>"GET"</code>, <code>"PUT"</code>).</desc>
106109
</property>
107110
<property name="mimeType" type="String" added="1.5.1">
108111
<desc>A mime type to override the <abbr title="XMLHttpRequest">XHR</abbr> mime type.</desc>
@@ -144,7 +147,7 @@ $.ajax({
144147
<desc>Set this to <code>true</code> if you wish to use the traditional style of <a href="/jQuery.param/">param serialization</a>.</desc>
145148
</property>
146149
<property default="'GET'" name="type" type="String">
147-
<desc>The type of request to make (e.g. "POST", "GET", "PUT"); default is "GET". </desc>
150+
<desc>An alias for <code>method</code>. You should use <code>type</code> if you're using versions of jQuery prior to 1.9.0.</desc>
148151
</property>
149152
<property default="The current page" name="url" type="String">
150153
<desc> A string containing the URL to which the request is sent.</desc>
@@ -346,7 +349,7 @@ $.ajaxSetup({
346349
<desc>Save some data to the server and notify the user once it's complete.</desc>
347350
<code><![CDATA[
348351
$.ajax({
349-
type: "POST",
352+
method: "POST",
350353
url: "some.php",
351354
data: { name: "John", location: "Boston" }
352355
})
@@ -387,7 +390,7 @@ xmlRequest.done( handleResponse );
387390
var menuId = $( "ul.nav" ).first().attr( "id" );
388391
var request = $.ajax({
389392
url: "script.php",
390-
type: "POST",
393+
method: "POST",
391394
data: { id : menuId },
392395
dataType: "html"
393396
});
@@ -405,7 +408,7 @@ request.fail(function( jqXHR, textStatus ) {
405408
<desc>Load and execute a JavaScript file.</desc>
406409
<code><![CDATA[
407410
$.ajax({
408-
type: "GET",
411+
method: "GET",
409412
url: "test.js",
410413
dataType: "script"
411414
});

0 commit comments

Comments
 (0)