【发布时间】:2015-12-16 10:29:58
【问题描述】:
我有这个代码:
function API() {
this.status = 'nothing';
}
API.prototype.search = function() {
this.status = 'searching';
$.ajax({
url: 'https://api.com',
data: {shapeFormat: 'raw'},
dataType: 'json',
timeout: 11000,
success: this.OK_callback,
error: this.KO_callback
});
}
API.prototype.OK_callback = function(data) {
console.log(this.status); // How to pass this value to the function?
}
API.prototype.KO_callback() {
this.status = 'done';
}
我如何访问this.status value insie OK_callback?
提前致谢!
【问题讨论】:
标签: javascript ajax object jquery-callback