I have chain of drop down like Country / state and City. Is there is any way to wait until the drop down population th开发者_StackOverflowen proceed further? like first load the country and then based on the select of an country then load the state and same as city....
function populateLists(listType) {
// on success do this:
$.ajax({
type:"POST",
url:"Wizard_Using_PageMethod.aspx/GetCountry",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType:"json"}
});
[WebMethod]
public static CountryList GetCountry()
{
CountryList country = new CountryList();
///go to db and get the data
return country;
}
You may do like this
$('#cb_country').change(function(){
var id=$(this).val();
$.get('getCity.php',{id:id},function(data){
$("#cb_city").html(data);
});
});
getCity.php:
<?php
require('../conn.php');
$id=$_GET['id'];
$Q=mysql_query("SELECT * FROM city WHERE CountryID='".$id."' ORDER BY Cityname ASC");
do{
echo "<option value='".$row['CityID']."'>".$row['CityName']."</option>";
}
while($row=mysql_fetch_assoc($Q));
精彩评论