0
这里是我的模型模型获取不起作用
urlRoot: '/users',
parse: function(response) {
return response.User;
}
的身体下面是当我在浏览器中键入/users/1
什么返回:
{"User":{"id":"1","created":"2013-02-13 09:22:42","modified":"2013-02-13 09:22:42","username":"somesuername","password":"","role":"somerole","token":null,"token_expiration":null}}
因此API的作品。 当我执行此:
this.model.id = 1;
this.model.fetch({ success: function(user){
console.log(user);
}}); // this.model is instance of my model
我得到了控制台:
d {cid: "c4", attributes: Object, _changing: false, _previousAttributes: Object, changed: Object…}
_changing: false
_pending: false
_previousAttributes: Object
attributes: Object
__proto__: Object
changed: Object
cid: "c4"
id: Array[1]
__proto__: e
所以结果是通过模型成功并没有取得任何数据 - 我这么想吗?
不 - 对不起,我粘贴控制台输出的格式不正确 - 扩展属性后只有这一行'__proto__:Object'是可见的。没有属性 - 我知道它是如何工作的,因为我的收藏工作正常,但型号不... – user606521 2013-02-19 17:46:18
@ user606521糟糕,没有注意到。您是否检查过浏览器开发人员工具中的响应,并确认服务器确实正在响应数据? – jevakallio 2013-02-19 17:48:37
@ user606521,有趣的是,您的模型'id'在检查器中是'Array [1]'。不知道怎么会出现这种情况,但我很确定这与你的问题有关。 – jevakallio 2013-02-19 17:51:58