function runimage(){
var vel = val.id;
var secondlink = 'someurl'+vel+'stuff';
$.getJSON(secondlink, function(beyta){
var target = beyta.attachments.data[0].media.image.src;
return target;
});
return "FISH";
}
I am making an API call via jQuery's getJSON
method. The problem I am having is getting the runimage()
function return the value of my target
value.
The code return target
gives me undefined
. This is the result even if I place a dummy string in place of target
.
To see if this is a problem with closures, I added a dummy return "FISH"
outside of my getJSON call, and the code does indeed return "FISH"
How would I go about getting runimage()
to return the value of variable target
?