异步请求、处理JSON对象

来源:互联网 发布:may it be中文歌词 编辑:程序博客网 时间:2024/05/22 15:54

JS:

 function ajaxRequest() {

            $.ajax(
                        {
                            type: "post",
                            url: "ABC.aspx?ajax=get",
                            dataType: 'html',
                            success: function (data) {
                                var word_data = eval(data);

                                ......

}});

}

C#: PAGE_LOAD 事件

 

 if ("get" == Request["ajax"])
            {
                AjaxHandle();
            }

 

 private void AjaxHandle()
        {
            Response.Clear();
            Response.ContentType = "text/html";

            string returnValue = "";

           

            List<Entryinfo> listEntry = new List<Entryinfo>();

           listEntry.Add(......)

            returnValue = JsonConvert.SerializeObject(listEntry);

            Response.Write(returnValue);
            Response.End();
        }

 [Serializable]
        public class Entryinfo
        {
            //父级类
            public string parent;
            //词条
            public string entry;
        }

   
原创粉丝点击