Jquery ajax konusunda örnek vereyim düzenle kendine göre:
Bu motor.php (ajaxdan gelen veriyi işleme sokacak php dosyası)
<?php
header('Content-type: text/HTML; charset=utf-8');
$ilceler = array();
if(isset($_POST["il"])):
switch($_POST["il"]){
case "6": $ilceler = array("Akyurt","Çankaya","Sincan"); break;
case "16": $ilceler = array("Osmangazi","Nilüfer","Yıldırım"); break;
case "34": $ilceler = array("Esenler","Bağcılar","Şişli"); break;
case "35": $ilceler = array("Aliağa","Buca","Konak"); break;
}
echo '<select id="ilceler">';
foreach($ilceler as $ilce){
echo '<option value="'.$ilce.'" >'.$ilce.'</option>';
}
echo "</select>";
endif;
?>Bu da index dosyası (İl ilçe seçim dosyası):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Deneme</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js "></script>
<script>
function getir(){
var secim = $("#iller").val();
if(secim == 0)return null;
$("#cikti").html("Lütfen bekleyiniz...");
$.ajax({
type: 'POST',
data: 'il='+secim,
url: 'motor.php',
success:function(e){
$("#cikti").html(e);
},
error:function(e){
$("#cikti").html("Sistem hatası.");
}
});
}
</script>
</head>
<body>
<select id="iller" onChange="getir()">
<option value="0" >Lütfen bir değer seçin.</option>
<option value="34" >İstanbul</option>
<option value="6" >Anakara</option>
<option value="16" >Bursa</option>
<option value="35" >İzmir</option>
</select>
<div id="cikti"></div>
</body>
</html>