【问题标题】:Highcharts Series from AJAXAJAX 的 Highcharts 系列
【发布时间】:2012-06-29 08:35:17
【问题描述】:

我遇到了从 .ASMX 返回的 Json 格式问题

我需要返回这样的东西

[{ name : "TEST1", data : [100]},
{ name : "TEST2", data : [200]}]

这是我的示例

 [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
    public List<jsonGraphSeries> Graph(string ID)
    {
       List<GenList>objGenList = new List<GenList>();
       GenList objlist;

       objlist = new GenList();
       objList.name = "TEST";
       objList.data[0] = 100;
       objGenList.add(objList);
     }



public class GenList
{
 public string name;
 public double[] data;
}

什么也没发生...有人可以帮我解决这个问题吗?

【问题讨论】:

标签: asp.net asmx highcharts webmethod


【解决方案1】:

你的方法没有返回任何东西,添加这个有用吗?

return objGenList;

【讨论】:

    【解决方案2】:

    愚蠢的我...为了让 json 将其识别为数组字段...

    而不是这样做......

    objList.data[0] = 100;
    

    我应该这样做......

     objlist = new GenList();
     objList.name = "TEST";
     objList.data = new [] {100};
     objGenList.add(objList);
    

    输出将是

    { name : "TEST1", data : [100]}
    

    【讨论】:

      猜你喜欢
      • 2011-12-24
      • 1970-01-01
      • 2013-08-08
      • 2013-05-25
      • 2013-05-23
      • 1970-01-01
      • 2013-09-03
      • 1970-01-01
      • 2023-03-10
      相关资源
      最近更新 更多