2015-07-19 76 views
2

我有以下代码聚合物1.0铁Ajax调用制作,但在响应不火和数据未绑定

<link rel="import" href="../bower_components/polymer/polymer.html"> 
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html" /> 


<dom-module id="custom-Element"> 
    <iron-ajax auto 
       url="http://api.openweathermap.org/data/2.5/forecast" 
       params='{"q":"California"}' 
       handle-as="json" 
       on-response="handleResponse" 
       last-response="{{ajaxResponse}}"></iron-ajax> 
    <span>{{ajaxResponse.city.name}}</span> 
    <script> 
     Polymer({ 
      is: 'custom-Element', 
      handleResponse: function() 
      { 
       console.log(' blalba'); 
      }, 
      ready: function() { 
       setInterval(function() { console.log(this.ajaxResponse); }, 1000); 

      } 
     }); 
    </script> 
</dom-module> 

我的问题是,即使在Ajax调用正在发生的事情和数据检索到on-response“handleResponse”方法永远不会被触发,并且“ajaxResponse”也不会被填充。我试着看着不同的教程和代码演示,但我似乎无法找到我的代码有什么问题。

+0

瞎猜 - 尽量把它的模板() - 如果你想要检查这个vid tuturial关于铁ajax - https://www.youtube.com/watch?v=ZDRCV8TzJZY – Tasos

+0

哇,这是正确的。非常感谢。 – rzvme

+0

是的,所有的dom模块都必须有一个'