1
我有這樣的代碼:如何將對象傳遞給jquery回調?
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
值insie OK_callback
? 在此先感謝!