Polymer 1.0 Iron-Ajax -
i trying data via php script works in polymer 0.5. null response , no errors in polymer 1.0, below code. have tried modifying php echo no response. hresponse fire @ point request information in ajax response information null. cannot find example see have gone wrong. thanks
<iron-ajax id="ajax" url="" params="" handle-as="json" on-response="hresponse" debounce-duration="300"> </iron-ajax> , script setajax: function(){ this.$.ajax.url = "scripts/getnotes.php"; this.$.ajax.params='{"sn":"vba056"}'; this.$.ajax.generaterequest(); } hresponse: function(e) { console.log(e.detail.response); console.log(this.$.ajax.lastresponse); }
when add this.$.ajax.params=
inside script, should object. when place inside iron-ajax.html request generated, see why case. adding string. try set line this.$.ajax.params={"sn":"vba056"}
, should work.
the following example works (assuming importing required elements):
<body> <my-app></my-app> <dom-module id="my-app"> <style> </style> <template> <iron-ajax id="ajax" url="" handle-as="json" on-response="hresponse" debounce-duration="300"> </iron-ajax> <button on-click="setajax">click me</button> </template> <script> polymer({ is: "my-app", setajax: function () { this.$.ajax.url = "http://jsonplaceholder.typicode.com/posts"; this.$.ajax.params = {"userid":"1"}; this.$.ajax.generaterequest(); }, hresponse: function(request) { console.log(request.detail.response); console.log(this.$.ajax.lastresponse); } }); </script> </dom-module> </body>
Comments
Post a Comment