You should use a callback pass to the function and let it deal your data.
function getfoo(callback) {
var foo = "";
$.get("foofile.html", function (data) {
callback(data);
// do some other things
// ...
});
}
getfoo(function(data) {
console.log(data);
});