我无法弄清楚我做错了什么。我的成功和错误回调没有触发,我正在从服务器返回 JSON 响应。关于我在哪里搞砸的任何想法?
mysite.city.delete_photo = {
"Model": Backbone.Model.extend({
"id": "deletePhoto",
"initialize": function initialize(id) {
this.url = "/assets/ajax/delete_image.php?img_id=" + id;
}
}),
"View": Backbone.View.extend({
"initialize": function initialize(id) {
_.bindAll(this,
"render",
"success");
this.model = new mysite.city.delete_photo.Model(id);
this.render();
},
"render": function render() {
this.model.destroy({
"cache": false,
"success": this.success,
"error": this.error
});
},
"success": function success(model, data) {
console.log("test");
},
"error": function error() {
message('error', 'This image could not be deleted.');
}
})
};