title: Scope of global variables in MVC View
body: <p>When I use global JavaScript variables in a View of MVC with Ajax, would the global variable be reset (re-declared) even though the page isn't refreshed? </p>
  
  <p>i.e.</p>
  
  <pre><code>&lt;script&gt;
  var global = 0;
  function func()
  {
       global = 2;
  
       //passing global variable to a method "int square(int number)" in Home Controller
        $.ajax(
          {
              type: "POST",
              url: "../Home/square",
              data: { number : global },
              success: function (result)
              {
                  alert(result);
              }
           };
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Generally, what events would cause global variables in JavaScript to reset?</p>