I've tried to solve this with async false, but to no avail.
I use the method below to call a poster with a JSON api I call which I letter assign to the global variable img_path.
function getPoster(id) {
var poster_path = null;
$.getJSON( "https://api.moviedb.org"+id+"?", {async: false}, function( data ) {
poster_path = data.poster_path;
}
}
For whatever reason, it doesn't work as the variable will still be "null" when I try to display it on my HTML-page. I checked in the and could confirm that the variables aren't reassigned properly. The reassignment doesn't work as if the global variable is outside the JSON-methods scope.
Help would be greatly appreciated!