json - polymer iron-form PUT method pass parameters in url -
i have problem , want use put method json data it's passing parameters in query string parameters , not in json, , can't find mistake. i'd not use 'iron-ajax' if possible.
<form is="iron-form" method="put" action="http://localhost:5000/users/" id="loginform" content-type="application/json"> <paper-input name="username" label="username" required auto-validate></paper-input> <paper-input name="password" label="password" type="password" required auto-validate></paper-input> <paper-button raised onclick="_submit(event)" disabled id="loginformsubmit"> <paper-spinner id="spinner" hidden></paper-spinner>submit</paper-button> <paper-button raised onclick="_reset(event)">reset</paper-button> <div class="output"></div> </form> <script> loginform.addeventlistener('change', function(event) { loginformsubmit.disabled = !loginform.validate(); }); function _submit(event) { spinner.active = true; spinner.hidden = false; loginformsubmit.disabled = true; polymer.dom(event).localtarget.parentelement.submit(); } function _reset(event) { var form = polymer.dom(event).localtarget.parentelement form.reset(); form.queryselector('.output').innerhtml = ''; } document.getelementbyid('loginform').addeventlistener('iron-form-submit', function(event) { spinner.active = false; spinner.hidden = true; loginformsubmit.disabled = false; this.queryselector('.output').innerhtml = json.stringify(event.detail); }); document.getelementbyid('loginform').addeventlistener('iron-form-response', function(response) { console.log(response); }); </script>
thank !
iron-form
includes parameters in body of post
requests. simplest workaround change method="put"
method="post"
, , add handler iron-form-presubmit
(fires after serialization) change method put
.
form.addeventlistener('iron-form-presubmit', function() { this.request.method = 'put'; });