Ajax working on localhost but not on server

Hi,

I am using Ajax autocomplete in my project. It autosuggests city name in text box.The code works fine on local server, but due to unknown reasons it is not working online.When I viewed page source, no errors were in consol and city list was populated as expected.Can anyone guide me in this issue?Here is part of my code:

  <script type="text/javascript">
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
      eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      if (restore) selObj.selectedIndex=0;
    }
    
    function getCities(countryid){
     jQuery('#loadingimage').show();
    	 			 jQuery.ajax({
    							type: "POST",
    							url: "http://cabsplease.com/wp-content/themes/cabsplease/getdropdown.php",
    							data:  "dropdowntype=country&countryid="+countryid,
    							success: function(msg){
    									 jQuery('#divCity').html(msg);
    									  jQuery('#loadingimage').hide();
    						   }
    						});
    }
    </script>
<script type="text/javascript">
function showlist(){
 <?php 
		  $rSql = "SELECT DISTINCT(city_name) FROM tbl_area";
		  $rResult = mysql_query($rSql);
		  if(mysql_num_rows($rResult)>0){
		  $str = '';
		  $flage = 0;
				while($rRow = mysql_fetch_assoc($rResult)){
					if($flage == 0) {
				 		$str = "'".$rRow['city_name']."'";
						$flage =1;
					}
					else{
						$str = $str.",'".$rRow['city_name']."'";
					}
				}
		  }	   
	  ?>
		var months = [<?php echo $str; ?>];
	$("#local_pickuparea").autocomplete(months,{           
		minChars: 0,
		max: 12,
		autoFill: false,
		mustMatch: false,
		matchContains: false,
		scrollHeight: 220,
		formatItem: function(data, i, total){
			return data[0];
		}
	});
	
		$("#mumairport_pickupdroparea").autocomplete(months,{             
		minChars: 0,
		max: 12,
		autoFill: false,
		mustMatch: false,
		matchContains: false,
		scrollHeight: 220,
		formatItem: function(data, i, total){
			return data[0];
		}
	});
	$("#outstation_pickarea").autocomplete(months,{           
		minChars: 0,
		max: 12,
		autoFill: false,
		mustMatch: false,
		matchContains: false,
		scrollHeight: 220,
		formatItem: function(data, i, total){
			return data[0];
		}
	});
	$("#outstation_droparea").autocomplete(months,{           
		minChars: 0,
		max: 12,
		autoFill: false,
		mustMatch: false,
		matchContains: false,
		scrollHeight: 220,
		formatItem: function(data, i, total){
			return data[0];
		}
	});

}
</script>
<script type='text/javascript' src='<?php bloginfo('template_url');?>/js/jquery.autocomplete.js'></script>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url');?>/css/jquery.autocomplete.css" />

<input type="text" id="local_pickuparea" name="local_pickuparea"  value="<?PHP if(isset($_POST['local_pickuparea'])){echo $_POST['local_pickuparea'];} ?>" onkeyup="showlist(this.value);"/>

fire up the browsers dev tools and check in the network section, what data this AJAX request sends and receives.

Thanks for your reply Dormilich.When I used network tool I found this line:
jquery.autocomplete.js GET 304 application/javascript cabsplease.com/:341 232 B 4.08 s
Not sure what does this means though!

A 304 response indicates that the resource for the requested URL has not changed since last accessed or cached.
Could you post a link to the live site?

that shouldn’t matter much, as jquery.autocomplete.js is just the library. but for the autocomplete to be useful, it needs to be configured to use either dynamic or static data.

Thanks Pullo and Dormilich. The link is : http://cabsplease.com/
PICKUP FROM : text box

No probs.

Looking at the console (F12 > Console) on the page you link to shows:

Uncaught ReferenceError: BookHistoryValidation is not defined Common.js:1006
Uncaught TypeError: undefined is not a function Common.js:20 

Not sure if they’re related, but you might want to look at fixing those.

Hello Pullo. I am at fixing those errors.But they have nothing to do with autocomplete.

Well the page is a bit of a mess to be honest.
For example, you are including jQuery 3 times (on line 144, 117, 246) and jQuery-UI twice (on line 147 & 516).
On WordPress (with which the site appears to be built), some plugins include their own version jQuery. Is it possible that you have a plugin installed on your live server that isn’t there locally?

Sorry for the mess. I cleaned the code in best possible way and autocomplete started working like a charm! :blush: had to do some adjustments to make calender work though.Thanks for your help.I will try to mess less next time :wink: