You may be familiar with this pattern, where a function is passed as an argument to another function.
$.get here is from the jQuery library; other AJAX libraries have similar functions.

Results

function callback(x) {
    log('received "' + x + '"');
}
 
function request() {
    $.get('request', callback);
}
 
request();