为了下次方便信手拈来!!
示例1
var form = document.forms["maddraddform"];
$(form.province).change(function(){
var post = {cache_time:0, id:$(this).val()};
app.fetchUrl(function(data){
if(data==false) {
J.showToast(fetch_err_msg, 'error', 2000);
return false;
}
if(typeof data == "string") data = eval('('+data+')'); if(data.ret == 1){
var obj = document.forms["maddraddform"].city;
$(obj).empty();
$(obj).append('<option value="0">请选择市</option>');
for(var i=0; i<data.list.length; i++){
$(obj).append('<option value="'+data.list[i].id+'">'+data.list[i].name+'</option>');
}
}else{
J.showToast(data.msg, 'error', 2000);
}
}, wsurl+'District/Lists/', post);
});
示例2
$('#ddlproducttype').change(function(){
$.ajax({
type: "POST",
url: MPATH + "/main/P/AgencyList.ashx",
data: {"producttype": $.trim($("#ddlproducttype").val())},
dataType: "json",
cache: !1,
success: function (result) {
$("#ddlissuers").empty();
$("#ddlissuers").append('<option value="">请选择发行机构</option>');
if (result.total>0) {
for(var i=0; i<result.rows.length; i++){
$("#ddlissuers").append('<option value="'+result.rows[i].id+'">'+result.rows[i].referred+'</option>');
}
}
}
});
});