$(document).ready(function(){
//通过洲获取国家
$("#continent").change(function(){
var opt = '';
$("select#country").empty();
$("select#country").append($("").text("请选择").attr("value", ""));
var requestUrl = '=site_url("/ajax/ajax_country")?>';
$.ajax({
dataType : "json",
url : requestUrl,
data: "id="+$(this).val(),
success : function(json){
if(json.result==1){
$(json.countryList).each(function(){
opt = $("").text(this.name).attr("value", this.id);
$("select#country").append(opt);
});
$("select#country").easyDropDown('destroy');
$("select#city").easyDropDown('destroy');
$("select#country").easyDropDown();
$("select#city").easyDropDown();
}
});
}else{
$("select#conutry").empty();
}
});
})
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29753604/viewspace-1394628/
,如需转载,请注明出处,否则将追究法律责任。