我有一个fetch()
在回调函数中$.post()
。从fetch()
后端抓取数据并更新集合就好了,但是当它运行它success
或error
回调时,什么都没有发生!我将console.log()
s 放在它的两个回调中,它们从未出现在 Javascript 控制台中。
知道发生了什么吗?
视图中的方法
create_set: function() {
var self = this;
// Post data to server
$.post('api/create_set', {
user_id: $('#user_id').val(),
post_id: this.post_id,
set_name: $('#new_set_name').val()
}, function() {
// Update list of Sets
self.setList.fetch({
data: {
user_id: $('#user_id').val(),
post_id: this.post_id
},
processData: true
}, {
success: function() {
// Highlight the first class in list
$(self.setListView.el).children('div:first').addClass('active');
console.log('success'); // DOESNT RUN!
}
}, {
error: function() {
console.log('error'); // DOESNT RUN!
}
});
console.log('hello'); // RUNS!
});
}