使用backbone.js我正在保存模型。将PUT发送到服务器并返回响应。我第一次这样做,它返回成功,以下时间返回一个错误,因为在第一次将响应添加到模型之后。
在Backbone.js中保存功能:
saveCountry: function() {
this.model.save({},{
success: function(model, response) {
console.log('success! ' + response);
},
error: function(model, response) {
console.log('error! ' + response);
}
});
this.render();
return false;
},
PHP返回一个JSON字符串:
{"response": "Model saved!"}
在PUT之后得到一个错误作为响应,因为“响应”被添加到模型中:
Unknown column 'response' in 'field list'
为什么响应会添加到模型中,我该如何预防?