由于json数据格式的简洁,语法简单,越来越受到web开发者的重视,在页面的异步加载上有明显的优势(优于XML)。
实例 -- 页面后台代码:(ashx处理文件)
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
public class Sockect : IHttpHandler
{
Hashtable hash = new Hashtable();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
GetCommentData();
}
private void GetCommentData()
{
string strmodel = HttpContext.Current.Request["model"];
switch (strmodel)
{
case "dataget":
sockdataget();//
break;
}
}
private void sockd