title: Jquery use one variable from one function to another function
body: <p>I write these functions in jquery. My one function is onclick and another one is onready function. I want to use this variable "loadmorecount_rest_num" in my onready function. How do I use this variable "loadmorecount_rest_num" in my onready function?</p>
  
  <p>I write these script for load more values from database in php using jquery.Now i want to  hide load more button if the data is "var loadmorecount_rest_num&lt;0".on ready function.
  Right now i hide that button using onclick event.I want to hide it using on ready event.</p>
  
  <pre><code>var STATUS= $('#status').val();
   var TYPE= $('#Property').val();
   var ADDRESS= $('#Address').val();
   var MINA= $('#min_area').val();
   var MAXA= $('#max_area').val();
   var MINP= $('#min_price').val();
   var MAXP= $('#max_price').val();
   var MINIMUMBED= $('#minbed').val();
   var MAXIMUMBED= $('#maxbed').val();
   var MINBATHROOM= $('#minbath').val();
   var MAXBATHROOM= $('#maxbath').val(); 
  
   var total_data_count= $('#total_data_count').val();
   var MINL = $("#minimum_limit").val();
   var current_data_count = $("#page_data_count").val();
   var MAXL = $("#maximum_limit").val();
   var new_start_limit= parseInt(MAXL)+parseInt(MINL);
   $("#minimum_limit").val(new_start_limit); 
   var data_start_limit_pass = $('#minimum_limit').val();
   var data_max_limit_pass = $('#maximum_limit').val();
  
  $.ajax({
  
              type : 'POST',
              url  : '&lt;?php echo MY_SITE_URL ;?&gt;'+'webapi.php',
                 data :{task:'Properties.loadmore',MINL:new_start_limit,MAXL:MAXL,STATUS:STATUS,TYPE:TYPE,ADDRESS:ADDRESS,MINA:MINA,
              MAXA:MAXA,MINP:MINP,MAXP:MAXP,MINIMUMBED:MINIMUMBED,MAXIMUMBED:MAXIMUMBED,MINBATHROOM:MINBATHROOM,MAXBATHROOM:MAXBATHROOM},   
                // data :{task:'Properties.loadmore',MINL:new_start_limit,MAXL:MAXL,get_data:get_data},  
              error: function() {
              console.log('somthing wrong');
              },
  
              success: function(response) {
                  var json_data= JSON.parse(response);
                  var Properties=json_data.Response;
                  var count = json_data.Response.length;
                  var old_current_data_count = $('#page_data_count').val(); 
                  var new_current_data_count= parseInt(old_current_data_count)+ parseInt(count);
                  $('#page_data_count').val(new_current_data_count);
  
                  var html='';  
  
                  $.each(Properties, function( key, value ) {
  
                      var nowDate = new Date();
                      var oneDay = 24*60*60*1000;
                      var secondDate = new Date(value.system_insert_date);
                      var diffDays = Math.round(Math.abs((nowDate.getTime() - secondDate.getTime())/(oneDay)));
                      // console.log(diffDays);
  
                      html = html+'&lt;div class="listing-item"&gt;';
                          html = html+'&lt;a href="#" class="listing-img-container"&gt;';
                              html = html+'&lt;div class="listing-badges"&gt;';
                                  html = html+'&lt;span&gt;'+value.current_status+'&lt;/span&gt;';
                              html = html+'&lt;/div&gt;';
                              html = html+'&lt;div class="listing-img-content"&gt;';
                                  html = html+'&lt;span class="listing-price"&gt;$'+value.close_price+'&lt;i&gt;'+value.list_price_per_sqft+'/ sq ft&lt;/i&gt;&lt;/span&gt;';
                                  html = html+'&lt;span class="like-icon"&gt;&lt;/span&gt;'; 
                              html = html+'&lt;/div&gt;'; 
                              html = html+'&lt;img src="images/listing-05.jpg" alt=""&gt;';
                          html = html+'&lt;/a&gt;';
  
                           html = html+'&lt;div class="listing-content"&gt;';
                              html = html+'&lt;div class="listing-title"&gt;';
                                          html = html+'&lt;h4&gt;&lt;a href="#" class="listing-address popup-gmaps"&gt;'+value.street_number+','+value.street_name+'&lt;/a&gt;&lt;/h4&gt;';
                                          html = html+'&lt;a href="https://maps.google.com/maps?q='+value.google_address+'" class="listing-address popup-gmaps"&gt;';
                                              html = html+'&lt;i class="fa fa-map-marker"&gt;&lt;/i&gt;';
                                              html = html+''+value.google_address+'';
                                          html = html+'&lt;/a&gt;';
                                          html = html+'&lt;a href="#" class="details button border"&gt;Details&lt;/a&gt;';
                              html = html+'&lt;/div&gt;';
                                  html = html+'&lt;ul class="listing-details"&gt;';
                                      html = html+'&lt;li&gt;'+value.sqft+' Sqft&lt;/li&gt;';
                                      html = html+'&lt;li&gt;'+value.beds+' Beds&lt;/li&gt;';
                                      html = html+'&lt;li&gt;N/A&lt;/li&gt;';
                                      html = html+'&lt;li&gt;'+value.bathfull+' Baths&lt;/li&gt;';
                                      html = html+'&lt;li&gt;'+value.bathhalf+' Half Baths&lt;/li&gt;';
                                  html = html+'&lt;/ul&gt;';
                                      html = html+'&lt;div class="listing-footer"&gt;';
                                          html = html+'&lt;a href="#"&gt;&lt;i class="fa fa-user"&gt;&lt;/i&gt;'+value.listing_office_name+'&lt;/a&gt;';
                                          html = html+'&lt;span&gt;&lt;i class="fa fa-calendar-o"&gt;&lt;/i&gt;'+diffDays+' Days ago&lt;/span&gt;';
                                      html = html+'&lt;/div&gt;';
                              html = html+'&lt;/div&gt;'; 
                          html = html+'&lt;/div&gt;';
  
  
                  });
                          $('#propertysearch').append(html);
                           $("#loadmore_btn").show();
                          $("#loadmorecount_rest").html('');
                          var loadmorecount_rest_num = parseInt(total_data_count)-(data_start_limit_pass)-(data_max_limit_pass);
                          $("#loadmorecount_rest").html(loadmorecount_rest_num);
                          var current_num_data=$('#page_data_count').val() ;
  
  
                             if(loadmorecount_rest_num==0 || loadmorecount_rest_num&lt;0){
  
                         $("#loadmore_btn").hide();   
                     }
                     else{
                        $("#loadmore_btn").show();
                     }      
  
  
          }
  }); 
  </code></pre>
  
  <p>});</p>
  
  <pre><code> $(document).ready(function(){
  
   });
  </code></pre>