So I've got this JS code here, and I'm trying to set obj from the success and error callbacks, but apparently the toLinkInfo
function scope is not a parent scope of those? I always get null back from this function no matter what. I tried a bunch of stuff but couldn't get it to work, I guess I'm too used to C & friends :) How can I get this to work?
LinkInfoGrabber.prototype.toLinkInfo = function() {
var obj = null;
$.ajax({
url: this.getRequestUrl(),
success: function(raw) {
obj = new LinkInfo(raw);
},
error: function(jqXHR, textStatus, errorThrown) {
obj = new LinkInfoException(jqXHR, textStatus, errorThrown);
},
dataType: 'html'
});
if (obj instanceof LinkInfo) {
return obj;
} else {
throw obj;
}
}