Except the fact that your code has errors like console.og()
in stead of console.log()
, your setup will never work.
You're trying to use a value that is set by an asynchronous request (that's what the XHR request is) inside synchronous code (this.temp
).
So, it's very likely that the code to create your HTML (the for
loop) is being executed BEFORE the XHR request has completed, and thus, before this.temp
has been initialized.
The reason that it works when using breakpoints is because you're delaying the HTML creation code until the XHR is completed (because you set a breakpoint).
There are two solutions here. The first one is by converting your XHR request to a synchronous request by setting the sync
option to true
. For more information look at the reference guide or the API documentation.
Another solution would be to make sure the code that creates your HTML is only being executed when the asynchronous request has been completed. You can do that by moving all your code that depends on this._temp
inside the callback (the function inside the then()
part).
However, if you need to return something from your callback, you will have to use deferreds.