Skip to content

Commit 090c011

Browse files
committed
Adds method option for API compatibility with newer versions of jQuery
resolves #486 Add 'method' option
1 parent 8e3e7b8 commit 090c011

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ String value that should be used for the iframe's src attribute when an iframe i
151151
### iframeTarget
152152
Identifies the iframe element to be used as the response target for file uploads. By default, the plugin will create a temporary iframe element to capture the response when uploading files. This options allows you to use an existing iframe if you wish. When using this option the plugin will make no attempt at handling the response from the server.
153153

154+
### method
155+
The HTTP method to use for the request (e.g. 'POST', 'GET', 'PUT').
156+
154157
### replaceTarget
155158
Optionally used along with the the target option. Set to true if the target should be replaced or false if only the target contents should be replaced.
156159

@@ -172,7 +175,8 @@ Callback function to be invoked after the form has been submitted. If a 'success
172175
Identifies the element(s) in the page to be updated with the server response. This value may be specified as a jQuery selection string, a jQuery object, or a DOM element.
173176

174177
### type
175-
The method in which the form data should be submitted, 'GET' or 'POST'.
178+
The HTTP method to use for the request (e.g. 'POST', 'GET', 'PUT').
179+
An alias for `method` option. Overridden by the `method` value if both are present.
176180

177181
### uploadProgress
178182
Callback function to be invoked with upload progress information (if supported by the browser). The callback is passed the following arguments:

docs/options.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ Default: `null`
8181
Identifies the iframe element to be used as the response target for file uploads. By default, the plugin will create a temporary iframe element to capture the response when uploading files. This options allows you to use an existing iframe if you wish. When using this option the plugin will make no attempt at handling the response from the server. **(version added: 2.76)**
8282

8383

84+
### method
85+
Default: value of form's `method` attribute (or `GET` if none found)
86+
The HTTP method to use for the request (e.g. 'POST', 'GET', 'PUT'). **(version added: 4.2.0)**
87+
88+
8489
### replaceTarget
8590
Default: `false`
8691
Optionally used along with the the [`target`](#target) option. Set to `true` if the target should be replaced or `false` if only the target _contents_ should be replaced. **(version added: 2.43)**
@@ -113,7 +118,8 @@ Identifies the element(s) in the page to be updated with the server response. Th
113118

114119
### type
115120
Default: value of form's `method` attribute (or 'GET' if none found)
116-
The method in which the form data should be submitted, 'GET' or 'POST'.
121+
The HTTP method to use for the request (e.g. 'POST', 'GET', 'PUT').
122+
An alias for `method` option. Overridden by the `method` value if both are present.
117123

118124

119125
### uploadProgress

src/jquery.form.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
options = {};
146146
}
147147

148-
method = options.type || this.attr2('method');
148+
method = options.method || options.type || this.attr2('method');
149149
action = options.url || this.attr2('action');
150150

151151
url = (typeof action === 'string') ? $.trim(action) : '';

0 commit comments

Comments
 (0)