Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
fix(method): throws exception on invalid method
Browse files Browse the repository at this point in the history
Instead, default to GET.

closes #62
  • Loading branch information
Ray Nicholus committed May 16, 2015
1 parent 52f5959 commit 4086609
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
5 changes: 2 additions & 3 deletions ajax-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,8 @@
// Need to look into this further.
ajaxForm.acceptableMethod = getValidMethod(ajaxForm.getAttribute('method'));

if (!ajaxForm.acceptableMethod) {
throw new Error('Invalid method!');
}
// default method is GET
ajaxForm.acceptableMethod = ajaxForm.acceptableMethod || 'GET';

watchForInvalidFields(ajaxForm);
interceptSubmit(ajaxForm);
Expand Down
22 changes: 13 additions & 9 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h1><code>ajax-form</code> in action:</h1>
<h1 id="pleaseWait" class="hidden">Sending your data...</h1>

<div id="content">
<form is="ajax-form" action="test" method="post">
<form is="ajax-form" action="test" method="post" enctype="multipart/form-data">
<div>
<label>Full Name: <input type="text" name="name" required></label>
</div>
Expand All @@ -69,10 +69,14 @@ <h1 id="pleaseWait" class="hidden">Sending your data...</h1>
<label>Favorite color: <input type="text" name="color"></label>
</div>

<input type="file" name="file">
<custom-checkbox role="checkbox" name="customcheckboxname" value="customcheckboxvalue">cust check</custom-checkbox>

<div>
<b>Receive periodic email updates from us?</b>
<input type="radio" name="emailCommunication" value="yes" checked>yes
<input type="radio" name="emailCommunication" value="no">no
<input type="checkbox" name="testcheck" value="testval">testcheck
</div>

<input type="submit">
Expand Down Expand Up @@ -143,14 +147,14 @@ <h3>Validation</h3>
// with the form submit. This is needed since the demo doesn't have
// a server to handle these requests.
(function() {
sinon.FakeXMLHttpRequest.useFilters = true;
sinon.FakeXMLHttpRequest.addFilter(function (method, url) {
return !(/test/).test(url);
});
var server = sinon.fakeServer.create();
server.respondWith([200, {}, '']);
server.autoRespond = true;
server.autoRespondAfter = 5000;
// sinon.FakeXMLHttpRequest.useFilters = true;
// sinon.FakeXMLHttpRequest.addFilter(function (method, url) {
// return !(/test/).test(url);
// });
// var server = sinon.fakeServer.create();
// server.respondWith([200, {}, '']);
// server.autoRespond = true;
// server.autoRespondAfter = 5000;
}());
</script>

Expand Down

0 comments on commit 4086609

Please sign in to comment.