Fixing These jQuery! A Guide to Debugging

You cannot combine the previous two non-working techniques to create something that works

Don’t feel bad, everybody tries this once

function getContent() {
  var stuff;
  $.get("remote.php",function(data) {
    stuff = data;
  });
  return stuff;
}
var newContent = getContent(); // newContent === undefined
This is a very bad idea. Just like $.get() does not wait for the callback to finish, neither will the containing getContent function