title: Access javascript global variable
body: <p>Following is my JavaScript. How do I make the variable <code>success</code> global so that the changes made in ajax->success are reflected outside?  </p>
  
  <pre><code>function foo() {  
      var success = false;  
      $.ajax({
  
          type: "POST",
          url: "",
          dataType: "xml",
          success: function(xml) {
              var code = parseInt($(xml).find("Response").attr("code"), 10);
              switch (code) {
                  case 1:
                      success = false;
                      break;
                  case 0:
                      success = true;
                      break;
              }
          }
      });
      return success;
  }
  </code></pre>