Answer the question
In order to leave comments, you need to log in
Why does loading the config work every other time?
Hello, please help. I can't understand why App.config is loaded every other time.
Intermittent error: Uncaught TypeError: _this.config.done is not a function
var App = function() {
this.init();
};
App.prototype = {
items: $.getJSON("/items.json", function(data) {
App.items = data;
}),
config: $.getJSON("/config.json", function(data) {
App.config = data;
}),
init: function() {
var _this = this;
_this.items.done(function() {
_this.config.done(function() {
_this.initConfig();
});
});
},
...............
}, $(document).ready(function() {
App = new App
});
Answer the question
In order to leave comments, you need to log in
Cured like this:
var App = function() {
this.init();
};
App.prototype = {
items: $.ajax({
url: "/items.json",
dataType: "json",
async: false
}),
config: $.ajax({
url: "/config.json",
dataType: "json",
async: false
}),
init: function() {
var _this = this;
_this.items.done(function(data) {
_this.items = data;
});
_this.config.done(function(data) {
_this.config = data;
_this.initConfig();
});
In general, items and config are called right when you create an object))))
you need to write like this
items: function(){
$.getJSON("
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question