Skip to content

Commit

Permalink
Adds method option for API compatibility with newer versions of jQuery
Browse files Browse the repository at this point in the history
resolves #486 Add 'method' option
  • Loading branch information
kevindb committed Mar 19, 2017
1 parent 457318f commit 55fba84
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ String value that should be used for the iframe's src attribute when an iframe i
### iframeTarget
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.

### method
The HTTP method to use for the request (e.g. 'POST', 'GET', 'PUT').

### replaceTarget
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.

Expand All @@ -172,7 +175,8 @@ Callback function to be invoked after the form has been submitted. If a 'success
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.

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

### uploadProgress
Callback function to be invoked with upload progress information (if supported by the browser). The callback is passed the following arguments:
Expand Down
8 changes: 7 additions & 1 deletion docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ Default: `null`
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)**


### method
Default: value of form's `method` attribute (or `GET` if none found)
The HTTP method to use for the request (e.g. 'POST', 'GET', 'PUT'). **(version added: 4.2.0)**


### replaceTarget
Default: `false`
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)**
Expand Down Expand Up @@ -113,7 +118,8 @@ Identifies the element(s) in the page to be updated with the server response. Th

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


### uploadProgress
Expand Down
2 changes: 1 addition & 1 deletion src/jquery.form.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
options = {};
}

method = options.type || this.attr2('method');
method = options.method || options.type || this.attr2('method');
action = options.url || this.attr2('action');

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

0 comments on commit 55fba84

Please sign in to comment.