1
我收到.save()
函数的错误响应。服务器端php返回一个文本,并成功地将该url保存到数据库中。当我检查响应我可以看到由PHP返回的文本,但我不明白为什么它会调用错误回调。可能是什么原因?与Backbone.js:奇怪的.save()错误回调
urlToAdd.save({}, {
success: function() {
console.log("In here");
},
error: function (model, response) {
console.log(model.toJSON());
console.log(response);
console.log("Not in here");
}
});
服务器响应:
HTTP/1.1 200 OK
Date: Sat, 19 May 2012 21:31:27 GMT
Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.6
X-Powered-By: PHP/5.3.6
Content-Length: 96
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
X-Pad: avoid browser bug
console.log再次打印什么?对不起,你的问题有点令人困惑。 –
感谢您的评论。控制台打印为'Object savetags.html:102 Object savetags.html:103 不在这里。第一个对象是模型,第二个是具有** responseText **的各种属性的对象,因为我的PHP页面返回 – Ali
什么是php响应的http代码?这就是它决定如何使用成功或失败。如果它不是2xx代码,那就是失败 –