title: How can i use ajax data variable use under submit button
body: <p>When I click submit button, I cannot receive the value <code>yearend</code>. Instead I got an undefined value. How can I get <code>yearend</code> value when I click submit button?</p>
  
  <p>My code:</p>
  
  <pre><code>$("#company").change(function() {
  
      $("#dFrom").val("");
      $("#dTo").val("");
      var pass_code = $("#company").val();
      var callpage = "dentrycomp.php?pass_code=" + pass_code
      var yearend= null;
      $.ajax({
          type: "GET",
          url: callpage,
          async: false,
          success: function(data) {
              yearend= data,
              $("#content").html("")
              $("#content").html(data)
          }
      });
      //var yearend = "&lt;?php echo $_SESSION['yearend'] ; ?&gt;"
      alert(yearend +"company");
      this alert box getting the right value yearend.i want that value recieve in under submit button                         
      return true;
  });
  
  
  $('#submit').live('click',function() {
  //var yearend = "&lt;?php echo $_SESSION['yearend'] ; ?&gt;"
  alert("this is submit button"+yearend);
  </code></pre>