problem facing in java script function returning value
I have two java script functions. from `validateSearchStirng()` i am calling `checkSolrServerAvailibility()`, from which i am expecting to return `flag=1` if ajax request is sucess otherwise `flag=0`. but each time `checkSolrServerAvailibility()` returning flag=0. Why so and what i need to do for getting correct result

   

     function validateSearchStirng(sort,order,itemPerPage,showPage)
        {
             var serverflag;
    serverflag=checkSolrServerAvailibility(sort,order,itemPerPage,showPage,query,solrURL);
             if(serverflag==0)
             {
        	var msg= "<hr /><font size="+size+" ><b>Solr Server Not Runing </b></font><hr /> ";
        	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&wt=json&&start="+start+"&      rows="+end+"&q="+query+"&json.wrf=?",
        		async:true,
        		dataType: 'json',
        		success: function(json){
        		flag=1;
        			return(flag);
        		}
        	})
           return(flag);
        
        }
    	
    	
    	
    } 



problem facing in java script function returning value
===

I have two java script functions. from `validateSearchStirng()` i am calling `checkSolrServerAvailibility()`, from which i am expecting to return `flag=1` if ajax request is sucess otherwise `flag=0`. but each time `checkSolrServerAvailibility()` returning flag=0. Why so and what i need to do for getting correct result

   

     function validateSearchStirng(sort,order,itemPerPage,showPage)
        {
             var serverflag;
    serverflag=checkSolrServerAvailibility(sort,order,itemPerPage,showPage,query,solrURL);
             if(serverflag==0)
             {
        	var msg= "<hr /><font size="+size+" ><b>Solr Server Not Runing </b></font><hr /> ";
        	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&wt=json&&start="+start+"&      rows="+end+"&q="+query+"&json.wrf=?",
        		async:true,
        		dataType: 'json',
        		success: function(json){
        		flag=1;
        			return(flag);
        		}
        	})
           return(flag);
        
        }
    	
    	
    	
    } 


