Polymer 1.x iron ajax-如何以编程方式更改响应?

Polymer 1.x iron ajax-如何以编程方式更改响应?,polymer,polymer-1.0,Polymer,Polymer 1.0,我想对几个服务器调用使用一个iron ajax元素,并且需要更改on response参数,类似于更改url参数。我看不出有什么办法…有人知道怎么做吗 这是我的铁元素: <iron-ajax id="xhr" handle-as="json" method="GET"> </iron-ajax> 随后: this.$.xhr.url = "server.com/getY"; this.$.xhr.onResponse = "handleY"; 以上这些都不行,我也不知

我想对几个服务器调用使用一个iron ajax元素,并且需要更改on response参数,类似于更改url参数。我看不出有什么办法…有人知道怎么做吗

这是我的铁元素:

<iron-ajax id="xhr" handle-as="json" method="GET">
</iron-ajax>
随后:

this.$.xhr.url = "server.com/getY";
this.$.xhr.onResponse = "handleY";
以上这些都不行,我也不知道该怎么做。我还尝试了这个$.xhr.onresponse、这个$.xhr.response和其他一些方法,但没有任何效果。感谢所有帮助。

没有
.onResponse
属性。响应时的
属性是注册事件处理程序的语法,是一个事件。要强制切换
响应
侦听器,您需要使用:


请注意,第三个参数是事件处理程序的方法名(一个
字符串
,而不是处理程序
函数
本身)。

谢谢您!我投了我的票,但显然我没有足够的声誉来改变显示的值…好吧!很抱歉
this.$.xhr.url = "server.com/getY";
this.$.xhr.onResponse = "handleY";
Polymer({
  ...
  _switchAjaxListener: function() {
    this.unlisten(this.$.xhr, 'response', '_oldListener');
    this.listen(this.$.xhr, 'response', '_newListener');
  }
);