title: jquery array push not working properly inside ajax success
body: <p>I am trying to push a div id into an array.Array push is working good bofore ajax call.But when i use push inside ajax success first push is taken place when i click on the second element.that is</p>
  
  <h2>array operation when with below code( array push inside success)</h2>
  
  <pre><code>first click on id="1"  --- resuting array []
  second click on id="2"  --- resulting array [1]
  second click on id="3"  --- resulting array [1,2]
  </code></pre>
  
  <p>my code</p>
  
  <pre><code>$(document).ready(function() {
  
      var count = 0;
      var vPool = '';
      arr = [];
      seat = [];
      var totalseat = '&lt;?php echo $sumofseat; ?&gt;';
      var date = ' &lt;?php echo $new_date; ?&gt;';
      $('.custom_checkbox').click(function() {
          pressed = true;
          var prev = $(this).attr('class');
          var arrid = $(this).attr('id');
          var seats = $(this).attr('title');
          count = $('.selected').length;
          if (prev == 'custom_checkbox') {
  
              //arr.push(arrid);
              //seat.push(seats);
              $.ajax({
                  url: "seat_manipulation.php",
                  dataType: 'json',
                  data: '&amp;operation=save&amp;seat=' + arrid + '&amp;guid=&lt;?php echo $guid; ?&gt;&amp;date=' + date,
                  type: "POST",
                  context: this,
                  success: function(data) {
  
                      if (data.status == 'SAVED') {
                          $(this).toggleClass('selected');
                          $('#count').slideDown();
                          $('#selecte_seat').show();
                          $('#count').html(count + ' Seats selected');
                          alert(arrid);
                          //if(jQuery.inArray(arrid,arr) == -1) {
                          arr.push(arrid);
  
  
                          //}
                          //if(jQuery.inArray(seats,seat) == -1) {
                          seat.push(seats);
                          //}
                      } else {
                          alert("Seat already been used.Please select another");
                      }
  
                  }
              })
  
          }
      });
  });
  </code></pre>
  
  <p>am i wrong..or this is how its suposed to work ?? Thanks in advance</p>