2015-07-19 52 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模塊都必須有一個'