【发布时间】:2013-10-12 19:42:13
【问题描述】:
所以这里没有什么特别的(这真的让我很烦)。 我很确定我缺少一些东西。
所以这是相对的代码:
_me.attributes.answers.push(oAnswer);
_me.save(null,{
success : function(){
console.log('saved the answer');
q = new q.Questions() ;
q.fetch({
success : function(data){
console.log('reloading the template with this data');
console.log(data)
this.render({model:data , el:this.$el})
}
})
},
error : function(model , response , x){
console.log('error')
console.log(response)
console.log(x)
}
});
现在我可以在控制台中看到已发出请求 (PUT) 并且服务器响应为 200 (OK) 。
但我仍然收到error 记录,当我尝试记录响应时,我得到了这个
readyState
4
responseText
"OK"
status
200
statusText
"OK"
仍然主干只是为 _me.save 触发 error 处理程序,这是为什么呢?
【问题讨论】:
-
所以你得到的错误不是
_me.save,而是q.fetch? -
你是从你的服务器返回一个空的身体吗?那是invalid response for jQuery。另一种可能性是:如果您从不同的域拨打电话,您的浏览器可能会尝试为您拨打CORS。
-
@glortho 是的,我在 _me.save 上收到错误,这是唯一的错误处理程序。
-
@j03w ,实际上我使用的是nodejs express,我发送的响应如下
res.send(200)。 -
@HusseinNazzal 所以听起来你需要改变这个:“仍然主干只是触发 q.fetch 的错误处理程序,为什么会这样?”