日期:2014-05-20  浏览次数:20807 次

json等于后台回调来的字符串,我想取key和value.怎样取呀. 谢谢
后台方法
[WebMethod]
  [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  public string show2()
  {
  return "{ \"options\": \"[{\"text\":\"王家湾\",\"value\":\"9\"},{\"text\":\"李家湾\",\"value\":\"10\"},{\"text\":\"邵家湾\",\"value\":\"13\"}]\" }";
  }


前台
$.ajax({
  url: "test.asmx/show2",
  type: "post",
  dataType: "json",
  contentType: "application/json;charset=utf-8",
  data: "{}",
  success: function(data) {
  var json = data;
  alert(json);
  for (var i in json) {
  alert(json[i]);
  }
  },
  error: function(msg) {
  alert("出错了!");
  }
  });


json[i] 返回的值


------解决方案--------------------
自己搞定了.