从服务器到客户端获取数据jquery c#

时间:2014-01-25 05:39:32

标签: c# jquery

这是服务器端的代码。我希望客户端的这个数据

protected void Page_Load(object sender, EventArgs e)
{
    if (Request.QueryString["action"] == "get")
    {
        populate();
    }
}

private void populate()
{
    List<Tree> TreeList = new List<Tree>();
    Tree tree = new Tree();
    tree.id = 0;
    tree.ref_id = 1;
    tree.name = "vendor";
    TreeList.Add(tree);


    tree = new Tree();
    tree.id = 1;
    tree.ref_id = 1;
    tree.name = "abc";
    TreeList.Add(tree);

    tree = new Tree();
    tree.id = 2;
    tree.ref_id = 1;
    tree.name = "xyz";
    TreeList.Add(tree);

    tree = new Tree();
    tree.id = 0;
    tree.ref_id = 2;
    tree.name = "Transformer";
    TreeList.Add(tree);

    tree = new Tree();
    tree.id = 1;
    tree.name = "Trans";
    tree.ref_id = 2;
    TreeList.Add(tree);
   // GetPageBaseObject = TreeList;

    //JObject jo = new JObject();
    //JArray jarray = (JArray)JToken.FromObject(GetPageBaseObject);
    //jo["data"] = jarray;
    //Response.Output.Write(jo.ToString());
    Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(TreeList, Formatting.Indented));

}

在客户端,我正在使用此

<script type="text/javascript">

//function Activityddl() {
alert("ok");
        var options = [];
        $.getJSON("AjaxHandler.aspx?action=get", function (result) {

            alert(result);
        });
  //  }

这个AjaxHandler页面将我重定向到我的原始页面.Plz帮助我没有将这些数据发送到客户端。

0 个答案:

没有答案