i'm trying to get the response from an iron-form in Polymer 1
.
Form submit call a php script which return HTML code to insert in a div
(ul
and some li
).
I use the iron-form
event "iron-form-response
" but i don't know how to get the response.
I can see the response in network tab of browser developer tools, but don't know how to get it in my element.
I don't find how to do in the iron-form
documentation online.
Can someone help me please ?
What's happening, guys? All these responses confuse the OP when it is only this simple:
Your form:
<form is="iron-form" on-iron-form-response="responseHandler" action="http://localhost" id="myform">
<!-- Your form elements -->
</form>
Your script:
<script>
Polymer({
// Some scripts here.
// ...now your listener
responseHandler: function(e) {
console.log(e.detail.response);
},
});
</script>
It's just that. Nothing complicated. Don't over-complicate things.
Add Event Listeners to iron form.
ready: function(){
this.$.myform.addEventListener('iron-form-response',this.formResponse);
this.$.myform.addEventListener('iron-form-error',this.formError);
}
Form Response Function:
formResponse: function (e){
console.log("Server Response: ",e.detail);
}
Form Error Function:
formError: function (e){
console.log("Form Error: ",e.detail);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With