title: How to clear the value of a javascript variable?
body: <p>I am using a javascript var to control the running of an ajax call.  The call is triggered from a click event (on "#week<code>_tag</code>" div)and only needs to be run once per page load.  The same click event also toggles the display of the sliding pane ("#week_summary") where the data from the ajax call is shown.  </p>
  
  <p>In the example below, I'm trying to use a variable and an if statement to prohibit the ajax call from being called when the user clicks the "#week<code>_tag</code>" div a second time to close the sliding pane.  The var status is set to "before" when the page is loaded, and set to "after" once the ajax call is made.  If the var status is equal to "before", the call is run, else the "#week_summary" is just toggled. It isn't working because I don't know how to give the var "status" a second value of "after".  Any ideas?</p>
  
  <pre><code>$(document).ready(function () {
      var status = "before";
      alert("before:" + status);
  
      $('#week_tag').click(function () {
          if (status == "before") {
              alert("afterclick:" + status);
              var form_date_set = $("input[name='date_set']").val();
  
              $.post("/tortus/index.php/daylog/build_summary",
                  { date_set: form_date_set },
                  function (html) {
                      $("#week_summary").html(html);
  
                      var status = "after";
                  });
          }
  
          $('#week_summary').toggle('blind');
  
          alert("after:" + status);
      });
  });
  </code></pre>