admin管理员组文章数量:1336568
Uncaught TypeError: this.$.ajax.generateRequest is not a function Polymer.setajax @ assets-ajax.html:23 handler @ polymer.html:390 assets-ajax.html
<dom-module id="assets-pull">
<style>
</style>
<template>
<button on-click="setajax">Click me</button>
<iron-ajax
id="ajax"
url=""
handle-as="json"
on-response="hresponse"
debounce-duration="300">
</iron-ajax>
</template>
<script>
Polymer({
is: "assets-pull",
setajax: function () {
this.$.ajax.url = "";
this.$.ajax.params = {"userId":"1"};
this.$.ajax.generateRequest();
},
hresponse: function(request) {
console.log(request.detail.response);
console.log(this.$.ajax.lastResponse);
}
});
</script>
Uncaught TypeError: this.$.ajax.generateRequest is not a function Polymer.setajax @ assets-ajax.html:23 handler @ polymer.html:390 assets-ajax.html
<dom-module id="assets-pull">
<style>
</style>
<template>
<button on-click="setajax">Click me</button>
<iron-ajax
id="ajax"
url=""
handle-as="json"
on-response="hresponse"
debounce-duration="300">
</iron-ajax>
</template>
<script>
Polymer({
is: "assets-pull",
setajax: function () {
this.$.ajax.url = "http://mytesturl./assets_all";
this.$.ajax.params = {"userId":"1"};
this.$.ajax.generateRequest();
},
hresponse: function(request) {
console.log(request.detail.response);
console.log(this.$.ajax.lastResponse);
}
});
</script>
Share
Improve this question
asked Aug 6, 2015 at 23:02
JerryJerry
9612 gold badges12 silver badges26 bronze badges
1 Answer
Reset to default 7Your code works for me. Make sure iron-ajax element is installed and imported.
Example:
<link rel="import" href="../ponents/iron-ajax/iron-ajax.html">
<dom-module id="assets-pull">
...
</dom-module>
本文标签:
版权声明:本文标题:javascript - Why am I getting "is not a function" error for generateRequest Polymer iron-ajax - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742385883a2465024.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论