title: Use while loop to pause javascript while waiting for AJAX response?
body: <p>I need to wait for an ajax response before continuing the code, otherwise a variable (data) is undefined. It would be difficult to rewrite the code to put the next portion all within its own function.</p>
  
  <p>The following while loop just crashes the browser, any ideas to do something similar to this, but that works?</p>
  
  <pre><code>name = getName(id);
  
  while (name == null || name == undefined) {
      //wait for response before continuing
  } 
  ...
  </code></pre>