在一個樣品,我有,他們已經模擬一個Ajax調用是這樣的:當你將某些東西綁定到超時時,這意味着什麼?
route('/page1', 'template1', function() {
this.greeting = 'Hello world!';
this.moreText = 'Loading...';
// Simulating an Ajax call which take 0.5 s
setTimeout(function() {
this.moreText = 'Bacon ipsum...';
}.bind(this), 500);
});
綁定似乎更新「本」,並引發
Object.observe(current.controller, current.render.bind(current));
更新一個視圖。
我嘗試與實際AJAX調用執行相同的事情:
route('/products', 'item_tmpl', function(){
this.products = []
$.getJSON('/data/list.json', function(data){
this.products = data;
//var dataObject = { products: data };
}).bind(this);
})
但是,返回undefined不是一個函數。