一个关于json和ajax的问题
前台:
function Change_Select()
{
var id = $("#sheng").val();
$.ajax({
async:false,
type: 'POST',
url: "tools/changesheng.ashx",
dataType: 'json',
data: { sid: id },
success: function (data) {
alert(data);
}
});
}
.cs:
context.Response.ContentType = "text/plain";
int id = Convert.ToInt32(context.Request.Form["sid"]);
DataSet dt= cityd.GetList("RootID="+id);
context.Response.Write(GetJsonByDataset(dt));
context.Response.End();
返回的json是一个object,内容是根据前一个下拉框的选择而出现的,如
{"ok":true,"ds":
[{"CityID":"101","CityName":"石家庄市","RootID":"5","Child":"0","Layer":"2","Sort":"1","Isopen":"1"},
{"CityID":"102","CityName":"唐山市","RootID":"5","Child":"0","Layer":"2","Sort":"2","Isopen":"1"},
{"CityID":"103","CityName":"秦皇岛市","RootID":"5","Child":"0","Layer":"2","Sort":"3","Isopen":"1"},
{"CityID":"104","CityName":"邯郸市","RootID":"5","Child":"0","Layer":"2","Sort":"4","Isopen":"1"},
{"CityID":"105","CityName":"邢台市","RootID":"5","Child":"0","Layer":"2","Sort":"5","Isopen":"1"},
{"CityID":"106","CityName":"保定市","RootID":"5","Child":"0","Layer":"2","Sort":"6","Isopen":"1"},
{"CityID":"107","CityName":"张家口市","RootID":"5","Child":"0","Layer":"2","Sort":"7","Isopen":"1"},
{"CityID":"108","CityName":"承德市","RootID":"5","Child":"0","Layer":"2","Sort":"8","Isopen":"1"},
{"CityID":"109","CityName":"沧州市","RootID":"5","Child":"0","Layer":"2","Sort":"9","Isopen":"1"},
{"CityID":"110","CityName":"廊坊市","RootID":"5","Child":"0","Layer":"2","Sort":"10","Isopen":"1"},
{"CityID":"111","CityName":"衡水市","RootID":"5","Child":"0","Layer":"2","Sort":"11","Isopen":"1"}]
}
现在我想把CityName加在第二个下拉框里面,请教这个json要怎么使用呢?