jquery ajax 返回json 为什么给下拉列表赋不上值

<scripttype="text/javascript"charset="utf-8">functionloadState(){$.ajax({type:"POST",... <script type="text/javascript" charset="utf-8">
function loadState() {
$.ajax({
type: "POST",
contentType: "application/json;charset=utf-8;",
url: "default.aspx/GetList",
data: "{code:'" + 130000000000 + "',areaLevel:'" + 1 + "'}",
dataType: "json",
success: function (results) {//返回 {"dt_area":[{"name":"北京","code":110000000000,"type":"PROVINCE","level":1,"area_Id":0,"areas_Id":""},{"name":"天津","code":120000000000,"type":"PROVINCE","level":1,"area_Id":7061,"areas_Id":""},{"name":"河北","code":130000000000,"type":"PROVINCE","level":1,"area_Id":12836,"areas_Id":""},{"name":"山西","code":140000000000,"type":"PROVINCE","level":1,"area_Id":67731,"areas_Id":""},{"name":"内蒙古","code":150000000000,"type":"PROVINCE","level":1,"area_Id":99468,"areas_Id":""},{"name":"辽宁","code":210000000000,"type":"PROVINCE","level":1,"area_Id":115330,"areas_Id":""},{"name":"吉林","code":220000000000,"type":"PROVINCE","level":1,"area_Id":133045,"areas_Id":""},{"name":"黑龙江","code":230000000000,"type":"PROVINCE","level":1,"area_Id":145774,"areas_Id":""},{"name":"上海","code":310000000000,"type":"PROVINCE","level":1,"area_Id":161859,"areas_Id":""}]}
var jsondata = JSON.parse(results.d);
var areadata = jsondata.dt_area;
getAreas(areadata);
},
error: function (results) {
alert("加载时出错,详情:" + results.responseText + ">>>" + results.statusText);
}
});
}
function getAreas(results) {
$. $.each(results, function (idx, item) {
var option = $("<option>").text(item.name).val(item.code);
ddlState.append(option);
});
}
$.fn.ready(function () {
loadState();
});
</script>

</head>
<body>
<form id="form1" runat="server">
<select name="state" style="width:80px;" class="default" tabindex="3">

</select>
</form>
</body>
function getAreas(results) {
$. $.each(results, function (idx, item) {
var option = $("<option>").text(item.name).val(item.code);
ddlState.append(option);
});
}
多贴了一个 , select里面就是没有结果阿
展开
 我来答
yugi111
2014-10-27 · TA获得超过8.1万个赞
知道大有可为答主
回答量:5.1万
采纳率:70%
帮助的人:1.3亿
展开全部
$. $.each(results, function (idx, item)

怎么2个$啊
追问
我多贴了一个$.   循环alert 有结果,但好像插入不到select里面阿
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式