惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
P
Palo Alto Networks Blog
C
Cisco Blogs
The Hacker News
The Hacker News
T
Threatpost
S
Schneier on Security
K
Kaspersky official blog
Spread Privacy
Spread Privacy
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
NISL@THU
NISL@THU
量子位
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google DeepMind News
Google DeepMind News
Security Latest
Security Latest
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
博客园 - 叶小钗
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
News and Events Feed by Topic
爱范儿
爱范儿
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Project Zero
Project Zero
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cisco Talos Blog
Cisco Talos Blog
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
T
Tenable Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Vulnerabilities – Threatpost
Forbes - Security
Forbes - Security
博客园 - 三生石上(FineUI控件)
C
Cyber Attacks, Cyber Crime and Cyber Security
N
News and Events Feed by Topic
V
V2EX
Webroot Blog
Webroot Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Blog — PlanetScale
Blog — PlanetScale
M
MIT News - Artificial intelligence
Scott Helme
Scott Helme
Simon Willison's Weblog
Simon Willison's Weblog
L
LangChain Blog
W
WeLiveSecurity
Cloudbric
Cloudbric

博客园 - symjie

每天学一点AS3.0(五)---声音的控制(5) 每天学一点AS3.0(四)---声音的控制(4) 每天学一点AS3.0(三)---声音的控制(3) 每天学一点AS3.0(二)---声音的控制(2) 每天学一点AS3.0(一)---声音的控制 javascript分页程序 - symjie - 博客园 初试jquery制作一个简单的loading delegate——委派 - symjie - 博客园 sql 分页 Ajax.net和GridView交互 Ajax.net实现loading登陆的效果 - symjie - 博客园 Ajax.net+模态窗口的登陆简单例子 GridView自定义分页(vb) - symjie - 博客园 用下拉列表控制gridview的分页 DataView数据组件 (转) c#冒泡程序 Atlas学习笔记 getElementByTagsName和相关函数的学习 基于Ajax.net的验证
Jquery json的超强组合 - symjie - 博客园
symjie · 2008-04-16 · via 博客园 - symjie

今天使用了jquery提供的对json的操作的函数,感觉超级爽哦!下面就把代码贴出
js

 1function getjson()
 2    {
 3      $("[id=ready]").remove();//返回id=ready的所有dom元素
 4
 5      $.ajax(
 6             {
 7                type:"get",
 8                dataType:"json",
 9                url:"jspage.aspx",
10                data:"id=1",
11                success:function(msg)
12                {
13                   var data=msg.bbslist; 
14                  //$("#databox").html(msg);
15                  //cleartext();
16                   $.each(data,function(i,n)
17                               {                                                                                          
18                                  var row=$("#temp").clone();
19                                  row.find("#listtile").text(n.listtile);
20                                  row.find("#listvalue").text(n.listvalue);
21                                  row.attr("id","ready");                                 
22                                  row.appendTo("#mainbox");
23                               }
 
24                  );
25               
26                }

27             }

28            );
29    }

html代码

 1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2<html xmlns="http://www.w3.org/1999/xhtml" >
 3<head>
 4    <title>Untitled Page</title>
 5    <link href="jspage.css" rel="Stylesheet" />
 6    <script language="javascript" src="../jscript/jquery.js"></script>   
 7</head>
 8<body onload="getjson();">
 9<div id="setpage"></div>
10<div id="mainbox">
11      <div id="temp">
12      <div id="listtile"></div>
13       <div id="listvalue"></div>
14      </div>
15</div>
16</body>
17</html>
18

C#

 1using System;
 2using System.Data;
 3using System.Configuration;
 4using System.Web;
 5using System.Web.Security;
 6using System.Web.UI;
 7using System.Web.UI.WebControls;
 8using System.Web.UI.WebControls.WebParts;
 9using System.Web.UI.HtmlControls;
10using System.Text;
11/// <summary>
12/// Summary description for DataTableToJSON
13/// </summary>

14public class DataTableToJSON
15{
16    public DataTableToJSON()
17    {
18        //
19        // TODO: Add constructor logic here
20        //
21    }

22    public static string DtToSON(DataTable dt)
23    {
24        StringBuilder jsonBuilder = new StringBuilder();
25        jsonBuilder.Append("{\"");
26        jsonBuilder.Append(dt.TableName.ToString());
27        jsonBuilder.Append("\":[");
28        for (int i = 0; i < dt.Rows.Count; i++)
29        {
30            jsonBuilder.Append("{");
31            for (int j = 0; j < dt.Columns.Count; j++)
32            {
33                jsonBuilder.Append("\"");
34                jsonBuilder.Append(dt.Columns[j].ColumnName);
35                jsonBuilder.Append("\":\"");
36                jsonBuilder.Append(dt.Rows[i][j].ToString());
37                jsonBuilder.Append("\",");
38            }

39            jsonBuilder.Remove(jsonBuilder.Length - 11);
40            jsonBuilder.Append("},");
41        }

42        jsonBuilder.Remove(jsonBuilder.Length - 11);
43        jsonBuilder.Append("]");
44        jsonBuilder.Append("}");
45        return jsonBuilder.ToString();
46    }

47}

48

这就是主要的代码了,相信各位都会组合吧,我就不再多介绍了,大家体会一下哈!