title: Where to CATCH an EXCEPTION thrown within an EVAL
body: <p>The following script enables you to run a piece of javascript code. Errors are being catched by the try / catch block.</p>
  
  <pre><code>    try {
          var result = eval(script);
      } catch (e) {
          // do something meaningful
      }
  </code></pre>
  
  <p>However, if the variable <code>script</code> contains for instance an AJAX call, and this ajax call throws an exception (e.g. in the success function), this exception will NOT be catched by this try / catch block...</p>
  
  <pre><code>    // execute an AJAX request
          var script = '$.ajax(url:"/somewhere", success: function(){throw new MyException('testexception')})';
      try {
          var result = eval(script);
      } catch (e) {
          // will not be triggered...
      }
  </code></pre>
  
  <p><strong>Question</strong>: how can I catch the exception thrown within the ajax request?</p>