假设我有以下内容:
var object = {
myfunc: function() {
$.ajax({
url: url,
format: format,
success: function() {
console.log(this) // This refers to the ajax call and not "object"
$.ajax({
url: url,
format: format,
success: function() {
console.log(this) // this refers to nested ajax call and not "object"
}
});
}
});
}
}
如何让“this”引用“object”而不是ajax调用?