乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      json學習筆記

       昵稱10504424 2012-08-03

      Json介紹:

        JSON(JavaScript Object Notation) 是一種輕量級的數據交換格式。易于人閱讀和編寫。
            json 官方網站 http://www./
            json.net 下載地址 http://json./releases/view/37810

      Demo:

        

      描述:

        點擊獲取按鈕后,將請求頁面,獲取json數據,填充到表格

      html代碼:

        

      復制代碼
      代碼
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www./1999/xhtml">
      <head runat="server">
      <title></title>

      <script type="text/jscript" src="../jquery/jquery-1.4.2.min.js"></script>

      <script language="javascript" type="text/javascript">
      $(
      function() {
      $(
      "#Button1").click(function() {
      $.get(
      "json1.aspx?m=m", null, function(callbackmsg) {
      var product = eval(callbackmsg);
      ShowProduct(product)
      })
      });
      })
      function ShowProduct(callbackmsg) {
      var row='';
      for (var u in callbackmsg) {
      var len = callbackmsg[u].length;
      row
      += '<tr>';
      row
      += '<td>' + callbackmsg[u].Name + '</td>';
      row
      += '<td>' + callbackmsg[u].Price + '</a></td>';
      row
      += '<td>' + callbackmsg[u].Size + '</td>';
      row
      += '</tr>';
      }
      $(
      "#body").html(row);
      }
      </script>

      </head>
      <body>
      <form id="form1" runat="server">
      <div>
      <input id="Button1" type="button" value="獲取" />
      </div>
      <table>
      <thead>
      <tr>
      <th>
      名稱
      </th>
      <th>
      價格
      </th>
      <th>
      大小
      </th>
      </tr>
      </thead>
      <tbody id="body">
      </tbody>
      </table>
      </form>
      </body>
      </html>
      復制代碼

      后臺代碼:

      復制代碼
      代碼
      public partial class json1 : System.Web.UI.Page
      {
      protected void Page_Load(object sender, EventArgs e)
      {
      if (HttpContext.Current.Request.QueryString["m"] != null)
      {
      List
      <Product> Products = new List<Product>();
      Products.Add(
      new Product() { Name = "筆記本", Price = "4.2", Size = "30x50" });
      Products.Add(
      new Product() { Name = "尺子", Price = "1.2", Size = "30x50" });
      Products.Add(
      new Product() { Name = "", Price = "36", Size = "30x50" });
      Products.Add(
      new Product() { Name = "鋼筆", Price = "6.0", Size = "30x50" });
      Products.Add(
      new Product() { Name = "鉛筆", Price = "2.2", Size = "30x50" });
      string json = JsonConvert.SerializeObject(Products);
      Response.Write(json);
      Response.End();
      }
      }
      }
      public class Product
      {
      public string Name { get; set; }
      public string Size { get; set; }
      public string Price { get; set; }
      }
      復制代碼

      知識點:

        1.json官方提供了用于.net操作的dll類庫,JsonConvert.SerializeObject將.net對象序列化為json。

        2.Javascript讀取json對象var product = eval(callbackmsg)。

        3.Javascript讀取json值callbackmsg[u].Name。

      分類: 其它
      標簽: jquery, json

        本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯系方式、誘導購買等信息,謹防詐騙。如發(fā)現有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多