我有一个包含子函数和对象的函数:
//API load function
var apiDataLoader = function () {
// Set default settings
this.apiSeason = '7924';
this.apiMatchDay = '30';
this.apiType = 'gamelist';
this.apiLink = 'http://example.com/';
this.apiLinkData = {
app: this.apiType,
season_num: this.apiSeason,
match_day: this.apiMatchDay
}
this.apiData = new Object;
//load API
apiDataLoader.prototype.load = function() {
$.ajax({
url: this.apiLink,
data: this.apiLinkData,
success: function(data) {
apiDataLoader.apiData = data; //this is not working
// I need to push somehow responce data to 'apiDataLoader.apiData' object
}
});
}
}
正如您在我的代码中看到的那样,我正在尝试将$.ajax
响应推送到名为:的父函数对象元素apidataLoader.apiData
,但我无法实现这一点。
有任何想法吗?
PS:值的响应data
是JSON
对象。