Here's the code I'm working with:
function retrieveSocialCount(type, filePath, executeCallback){
var request = new XMLHttpRequest();
request.onload = function(){
if(request.status === 200 && request.readyState === 4){
var countResponse = JSON.parse(request.responseText);
executeCallback(countResponse);
}
}
request.open("GET","../scripts/php/getSocialCount.php",false);
request.send();
}
var result = retrieveSocialCount("img", "example.png", function(count){
return count;
});
console.log(result);
However, when I try to use result
, it turns out to be undefined. The AJAX call is successful and returns an object. Any ideas on what might be causing this issue?