【问题标题】:jquery + ajax + json + fill dropdown list not workingjquery + ajax + json + 填充下拉列表不起作用
【发布时间】:2009-11-17 10:28:35
【问题描述】:
我很确定我快到了....但我无法弄清楚如何遍历 json 对象并填写下拉列表。这是js代码:
我的 JSON 数据返回:<pre>{"name":"County1","name":"County1","name":"County1"}</pre>
<pre></pre>
$(文档).ready(函数() {
$("#ddlCountries").change(function() {
$("#ddl2").html("");
$.ajax({
类型:“获取”,
url: "Handler.ashx?",
数据:"county=" + $("#ddlCountries 选项:已选择").text(),
contentType: "应用程序/json; charset=utf-8",
数据类型:“json”,
成功:函数(countyList){
$.each(countyList, function() {
$("#ddl2").append(' + this['name'] + '');
});
},
错误:函数(XMLHttpRequest,textStatus){
警报(文本状态);
}
});
});
});
我确定这很简单,但由于我是这方面的新手,所以我无法让它发挥作用。
感谢您的帮助!
兄弟,
特谢拉
【问题讨论】:
标签:
jquery
ajax
json
drop-down-menu