Skip to content

Commit fc63992

Browse files
committed
change default form method from POST to GET
per HTML spec http://www.w3.org/TR/html401/interact/forms.html#h-17.3
1 parent de5a822 commit fc63992

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/rails.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@
1919
dataType = element.attr('data-type') || ($.ajaxSettings && $.ajaxSettings.dataType);
2020

2121
if (element.is('form')) {
22-
method = element.attr('method') || 'POST';
22+
method = element.attr('method');
2323
url = element.attr('action');
2424
data = element.serializeArray();
2525
// memoized value from clicked submit button
2626
var button = element.data('ujs:submit-button');
2727
if (button) data.push(button);
2828
} else {
29-
method = element.attr('data-method') || 'GET';
29+
method = element.attr('data-method');
3030
url = element.attr('href');
3131
data = null;
3232
}
3333

3434
$.ajax({
35-
url: url, type: method, data: data, dataType: dataType,
35+
url: url, type: method || 'GET', data: data, dataType: dataType,
3636
// stopping the "ajax:beforeSend" event will cancel the ajax request
3737
beforeSend: function(xhr, settings) {
3838
if (settings.dataType === undefined) {

test/public/test/call-remote.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ test('form method is not read from "data-method" attribute in case of missing "m
4141
build_form({ 'data-method': 'put' });
4242

4343
submit(function(e, data, status, xhr) {
44-
App.assert_post_request(data.request_env);
44+
App.assert_get_request(data.request_env);
4545
});
4646
});
4747

48-
test('form default method is POST', function() {
48+
test('form default method is GET', function() {
4949
expect(1);
5050
build_form();
5151

5252
submit(function(e, data, status, xhr) {
53-
App.assert_post_request(data.request_env);
53+
App.assert_get_request(data.request_env);
5454
});
5555
});
5656

0 commit comments

Comments
 (0)