I need to access this from my setInterval handler
prefs: null,
startup : function()
{
// init prefs
...
this.retrieve_rate();
this.intervalID = setInterval(this.retrieve_rate, this.INTERVAL);
},
retrieve_rate : function()
{
var ajax = null;
ajax = new XMLHttpRequest();
ajax.open('GET', 'http://xyz.example', true);
ajax.onload = function()
{
// access prefs here
}
}
How can I access this.prefs in ajax.onload?
The setInterval line should look like this:-
Edit: The same principle applies to the "
onload". In this case its common for the "outer" code to do little, it just sets up the request an then sends it. In this case the extra overhead an additinal function as in the above code is unnecessary. Your retrieve_rate should look more like this:-