I have a function that calls another function and I want to store the returned result in a variable:
function trigger_gridly(){
var channel_name = get_channel_name();
}
The called function triggers an AJAX request, which triggers a callback receiving JSON:
function get_channel_name(){
var channel_name;
$.getJSON(APPLICATION_DOMAIN + "channels/new.json?callback=?", null, handleJson);
}
function handleJson(channel){
var channel_name = channel.name;
return channel_name;
}
The problem is that the channel_name
in trigger_gridly()
does not receive the value of channel_name
in the handleJson
callback function. How can I expose the data in the callback to the trigger_gridly()
function?