当我运行页面时,在控制台中你可以看到很多人对iron-ajax的调用,我不知道为什么,请帮忙:
<iron-ajax
auto id="GetDatUsr"
url="http://myserver/servweb/all_repusr.php"
handle-as="json"
on-response="menuxuser"
last-response="{{userdata}}"
debounce-duration="300">
</iron-ajax>
功能是:
menuxuser: function(){
var email1 = this.emailData();
this.$.GetDatUsr.params = { email: email1};
this.roll1 = this.$.GetDatUsr.lastResponse;
var count = Object.keys(this.$.GetDatUsr.lastResponse).length;
var roll3 = 0;
for (var i = 0; i < count; i += 1) {
roll3 = this.roll1[i]["roll"];
}
this.hideMenu(roll3);
}
计算是正确的,但它继续无限运行。
答案 0 :(得分:1)
删除auto
,document说;
auto: boolean = false
If true, automatically performs an Ajax request when either url or params changes
因此,每当更换参数时,铁-ajax就会发射。相反,您需要在需要时手动触发iron-ajax
:
this.$.GetDatUsr.generateRequest();