1
我只是不知道如何在ajax成功中調用另一個聚合函數。聚合物!在Ajax成功中調用函數
這是我的代碼:
<script>
(function() {
// these variables are shared by all instances of app-globals
var firstName = "John";
function setData(data) {
firstName = data;
console.log("Data gesetzt:" + firstName);
}
Polymer({
ready: function() {
this.setTest("Example"); //Works
$.ajax({
async: false,
type: "GET",
url: "http://www.jsv-lippstadt.de/?json=get_category_posts&slug=" + this.from,
dataType: 'jsonp',
error: function() {
alert('Unable to load feed, Incorrect path or invalid feed');
},
success: function (data) {
this.setTest(); //Doesnt work
}
});
},
setTest: function() {
console.log("hi");
}
});
})();
</script>
那從成功的功能控制檯日誌:遺漏的類型錯誤:未定義是不是一個函數。
那麼如何在我的回調中調用setTest:function(){}?
哇,謝謝你。很簡單!^^ – 2015-01-26 18:44:47