标签:one count show *** ring ++ write exp style
ajax:
一般处理程序(数据接口):ashx
跨语言传递数据:
xml:
结构不清晰
代码量比较大
查找起来比较费事
非面向对象结构
json:
结构清晰
代码量相对较小
面向对象的处理解析方式,查找数据很简单
键值对
{"key1":"value","key2":"value"}
多个对象的json
[{"key1":"value","key2":"value"},{"key1":"value","key2":"value"},{"key1":"value","key2":"value"}]
引用jQuery后
$.ajax({ url: "ajax/***.ashx", data: {"key1":"value","key2":"value"}, type: "post", dataType: "json", success: function (data) { } });
ashx文件
1 string c = context.Request["code"]; 2 List<China> ulist = new ChinaData().Select(c); 3 4 string json = "["; 5 6 7 int count = 0; 8 foreach (China u in ulist) 9 { 10 if (count > 0) 11 { 12 json += ","; 13 } 14 15 json += "{\"AreaCode\":\"" + u.AreaCode + "\",\"AreaName\":\"" + u.AreaName + "\"}"; 16 count++; 17 } 18 19 json += "]"; 20 21 context.Response.Write(json); 22 context.Response.End();
.
标签:one count show *** ring ++ write exp style
原文地址:http://www.cnblogs.com/hqxc/p/6287368.html