我是新来的骨干,但我已经写了一个基本模型,并试图为我的模型获取数据。我知道服务器正在返回数据,但抓取正在调用错误回调。你如何找到由骨干获取产生的错误
这很好,但我不知道如何找到正在生成的错误。
下面是相关代码:
mUser = Backbone.Model.extend({
urlRoot: CURRENT_URL+'user',
defaults: {
name: '',
age: 22,
email: ''
},
initialize: function(){
}
});
user = new mUser({'id':1});
var x = user.fetch({
error: function(model, xhr, options){
alert('Error on fetch')
console.log(xhr.responseText);
},
success: function(model, response, options) {
alert(user.toJSON());
}
})
console.log('x email',x.email)
正如我所提到的,这个responseText确实有我期望从服务器看到的数据,那就是:
{ 'ID': '1', 'name':'joe','age':'25','email':'[email protected]'}
也许我应该提一下,我是这样做的,作为PhoneGap android应用程序的一部分。我不认为这对我遇到的问题很重要,但它确实限制了我的调试选项。
你检查过http状态码吗? – soulcheck 2013-03-12 14:12:44
服务器发送一个200.我应该提到这一点。 – 2013-03-12 14:19:08
什么是CURRENT_URL值,以及如何监控请求? – soulcheck 2013-03-12 14:24:10