1.new httphandler:
<%@ WebHandler Language="C#" Class="AjaxHandler" %>
using System;
using System.Web;
public class AjaxHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
System.Collections.Generic.List<System.Collections.Generic.Dictionary<string, string>> parent = new GucDataFetchEntLib.GucAddressingDao().GetDataCenter();
System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
context.Response.Write(js.Serialize(parent));
}
public bool IsReusable
{
get
{
return false;
}
}
}
2.call httphandler in page
function ajaxPageMethod() {
$.ajax({
type: "GET",
contentType: "application/json",
url: "AjaxHandler.ashx",
success: function (list) {
alert(list);
$("#result").html(list);
},
error: function (xhr) {
$("#result").html("request wcf sever error!");
}
});
}