当前位置: 代码迷 >> ASP.NET >> 请问:为什么获取不到json对像的值
  详细解决方案

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

热度:4616   发布时间:2013-02-25 00:00:00.0
请教:为什么获取不到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);  }  });  }
  相关解决方案