读书人

请问:为什么获取不到json对像的值

发布时间: 2012-04-06 12:22:24 作者: rapoo

请教:为什么获取不到json对像的值?
function GetCity() {
var proid = $("#ProID").val();
$("#CityID").empty();
$.ajax({
url: "/Registers/GetCityByProID?id=" + proid,
type: 'GET',
success: function (json) {
var html = '';
for (var i = 0; i < json.length; i++) {
html += '<option value="' + json[i].value + '">' + json[i].text + '</option>';
}
// alert(html);
$(html).appendTo($("#CityID"));

}
});
}


为什么得到的值总是:undefined,怎样才真正获取数据,哪里出问题了,请高手帮帮忙!

[解决办法]

JScript code
function GetCity() {  var proid = $("#ProID").val();  $("#CityID").empty();  $.ajax({  url: "/Registers/GetCityByProID?id=" + proid,  type: 'GET',  dataType: 'json' //增加一个  success: function (json) {      alert(json);  },  error: function(msg) { //增加这个,看看是什么出错      alert(msg.responseText);  }  });  } 

读书人网 >asp.net

热点推荐