In an object I have a method where I want to get some information from a server(JSON format). I want to add this data to my object where the function is (By using a setter). The problem is that this isn't my object but the jquery callback. How could/should I solve this?
function anObject() {
$.get(URL, doTheCallback);
function setExample(example) {
this.example = example;
}
function doTheCallback(data) {
this.setExample(data.results[0].example);
}
}