Below is my JQuery code. I just added an 'alert' to test whether data is retrieved correctly or not. But this code is not working. I think it is simply not able to get inside the file "filldistricts.php".
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.js" />
<script type="text/javascript">
$(document).ready(function(){
$("#inDistrict").change(function(){
$.getJSON("filldistricts.php",function(j){
alert(j[0]);
})
})
})
</script>
Below I am giving the code of "filldistricts.php":
<?php
$query = "SELECT districtid FROM districtmaster";
try
{
$result = mysql_query($query);
$c = "";
while($row = mysql_fetch_assoc($result))
{
$c = $c.$row['districtid'].",";
}
$c = $c."Select";
echo json_encode(array($c));
}
catch(exception $ex)
{
echo "<script type='text/javascript'>alert('".$ex."');</script>";
}
?>
Where is the problem?