title: problem facing in javascript function returning value
body: <p>I have two javascript functions. from <code>validateSearchStirng()</code> i am calling <code>checkSolrServerAvailibility()</code>, from which i am expecting to return <code>flag=1</code> if ajax request is successful otherwise <code>flag=0</code>. but each time <code>checkSolrServerAvailibility()</code> returning flag=0. Why so and what i need to do for getting correct result</p>
  
  <pre><code> function validateSearchStirng(sort,order,itemPerPage,showPage)
      {
           var serverflag;
  serverflag=checkSolrServerAvailibility(sort,order,itemPerPage,showPage,query,solrURL);
           if(serverflag==0)
           {
          var msg= "&lt;hr /&gt;&lt;font size="+size+" &gt;&lt;b&gt;Solr Server Not Runing &lt;/b&gt;&lt;/font&gt;&lt;hr /&gt; ";
          removeList();
          $("#result").html(msg); 
           }  
           if(serverflag==1)
           {
             getSolrResponse(sort,order,itemPerPage,showPage,query,solrURL);  
           }
  
      }
  
  
   function checkSolrServerAvailibility(sort,order,itemPerPage,showPage,query,solrURL)
      {
          var start=itemPerPage*(showPage-1);
          var end=itemPerPage;
          var flag=0
          $.ajax({
              url: solrURL+"/solr/db/select/?qt=dismax&amp;wt=json&amp;&amp;start="+start+"&amp;      rows="+end+"&amp;q="+query+"&amp;json.wrf=?",
              async:true,
              dataType: 'json',
              success: function(json){
              flag=1;
                  return(flag);
              }
          })
         return(flag);
  
      }
  
  
  
  } 
  </code></pre>