So I want to return a string from within a function that gets formed two AJAX calls deep. I can figure out a messy way of doing this, but I imagine there is a better way to do this?
function fetchAndFillTemplate(options) {
$.getJSON(options.data, {}, function(data, status) {
$.get(options.template, function(template) {
// this is the string I want to return when you call 'fetchAndFillTemplate'
var rendered_template = Mustache.to_html(template, data);
});
});
}