响应为200时,骨干保存会触发错误

时间:2013-10-12 19:42:14

标签: javascript backbone.js

所以没什么特别的好处(这真的让我烦恼)。 我非常肯定有一些东西是我遗失的。

所以这里有一些相对的代码:

    _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"

仍然主干只会触发error的{​​{1}}处理程序,为什么会这样?

1 个答案:

答案 0 :(得分:1)

根据解析功能,您的服务器响应无效。保存时,请尝试将“parse:false”传递给模型选项

model.save(attrs, {
  success: function() { ... },
  parse  : false
});
相关问题