0
格式化Ember.js,我爲返回AJAX,一個頁面上格式:JSON爲灰燼
{
"foo": [
{
"foo1": "1",
"foo2": "2"
}
],
"bar": [
{
"bar1": "1",
"bar2": "2"
}
]
}
這是通過加載:
App.PostsRoute = Ember.Route.extend({
model: function(params) {
return jQuery.post('http://url/ajax', {
s: params.query,
}, function(){}, 'json');
}
});
但灰燼拋出錯誤(即使有僅限靜態內容模板):
Error while processing route: posts undefined is not a function TypeError: undefined is not a function
at m.extend._setupArrangedContent (http://cdnjs.cloudflare.com/ajax/libs/ember.js/1.6.0/ember.min.js:13:29556)
at ...
TypeError: undefined is not a function
at m.extend._setupArrangedContent (http://cdnjs.cloudflare.com/ajax/libs/ember.js/1.6.0/ember.min.js:13:29556)
at ...
如果不返回任何內容,則僅加載靜態內容模板。這導致我相信錯誤是在JSON格式,但JSON的作品http://tryhandlebarsjs.com/
「foo1」和「foo2」代表什麼?在兩種情況下,這應該是「身份證」嗎? –
你能否提供一個更完整的例子作爲jsbin? PostsRoute對我來說看起來很好。 – Oliver
試試這個return jQuery.post('http:// url/ajax',{ s:params.query, })。then(function(response){return response;}); – blessenm