wcf json asp.net json
function BindNewsTypeTree() {
var parentid;
// $.getJSON(serviceUrl + "NewsTypeService.svc/GetNewsTypeTreeJson?jsoncallback=?",
$.getJSON(serviceUrl + "NewsTypeService.aspx?jsoncallback=?",
{ siteID: siteID, isNewsType: true, fun: 'GetNewsTypeTreeJson' },
function (data) {
// alert(data);
$('#treeNews').tree('loadData', $.parseJSON(data));
SetSelectedNode();
});
});
}
if (!IsPostBack)
{
System.Collections.Specialized.NameValueCollection querylist = Request.QueryString;
if (querylist == null)
{
Response.End();
}
else
{
string fun = querylist["fun"];
string result = "";
if (fun == "GetNewsTypeTreeJson")
{
result = ToJSON(GetNewsTypeTreeJson(C_int32(DG_keyVale(querylist, "siteID")), C_bool(querylist["isNewsType"])));
}
else if (fun == "GetPageEntityList") {
result = ToJSON(GetPageEntityList(C_int32(DG_keyVale(querylist, "siteID")), C_int32(DG_keyVale(querylist, "parentID")), C_int32(DG_keyVale(querylist, "pageIndex")), querylist["name"]));
}
else if (fun == "DeleteData") {
result = ToJSON(DeleteData(C_int32(DG_keyVale(querylist, "siteID")), C_int32(DG_keyVale(querylist, "id"))));
}
Response.Clear();
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "application/json";
if (!string.IsNullOrEmpty(result))
{
if (querylist["jsoncallback"] != "")
{
JavaScriptSerializer jss = new JavaScriptSerializer();
Response.Write((querylist["jsoncallback"] + "(" + jss.Serialize(result) + ");"));//+ "\""这里要注意的
}
else
{
Response.Write(result);
}
}
Response.Flush();
Response.End();
}
}