• <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
  • <th id="l3qpx"><progress id="l3qpx"></progress></th>
      <th id="l3qpx"></th>
      <dd id="l3qpx"><font id="l3qpx"></font></dd>
      <th id="l3qpx"></th>
      0712-2888027 189-8648-0214
      微信公眾號(hào)

      孝感風(fēng)信網(wǎng)絡(luò)科技有限公司微信公眾號(hào)

      當(dāng)前位置:主頁(yè) > 技術(shù)支持 > Javascript/JQuery > 使用Ajax請(qǐng)求json數(shù)據(jù)并顯示在頁(yè)面中的示例代碼

      使用Ajax請(qǐng)求json數(shù)據(jù)并顯示在頁(yè)面中的示例代碼

      時(shí)間:2017-08-30來(lái)源:風(fēng)信官網(wǎng) 點(diǎn)擊: 1303次
      以下示例為使用Ajax請(qǐng)求json數(shù)據(jù)并顯示在頁(yè)面HTML中的代碼,請(qǐng)求數(shù)據(jù)及json數(shù)據(jù)轉(zhuǎn)換形式供參考:

      使用Ajax請(qǐng)求json數(shù)據(jù)并顯示在頁(yè)面中的示例代碼
      $.ajax({
          url: '/ajax/getFloorManageByBuildingManageID',
          type: 'post',
          Data: {"building.id": id},
          dataType: 'json',
          success: function(data){
              $('#floorManagerList').text(''); //將樓層內(nèi)容清空
              var floor = "";
              var obj = json.pares(data);
              for(var i=0; i<data.length; i++){
                  floor += "<li class='bed-on'><div class='col-sm-8 pd-left'>"+obj[i].floorname+"</div>"+
                          "<div class='col-sm-4 bed-edit'><a data-toggle='modal' data-target='#myModal'>"+
                          "<i class='icon inconfont'>&#xe662;</i></a>"+
                          "<a><i class='icon iconfont'>&#xe600;</i></a>"+
                          "</div>"+
                          "</li>";
              }
              $('#floorManagerList').html(floor);
          }
      });

      說(shuō)明:使用json.pares轉(zhuǎn)換為json對(duì)象

      1.parse 用于從一個(gè)字符串中解析出json 對(duì)象。例如

      var str='{"name":"cpf","age":"23"}'

      經(jīng) JSON.parse(str) 得到:

      Object: age:"23"

                  name:"cpf"

                  _proto_:Object

      ps:單引號(hào)寫(xiě)在{}外,每個(gè)屬性都必須雙引號(hào),否則會(huì)拋出異常

      2.stringify用于從一個(gè)對(duì)象解析出字符串,例如

      var a={a:1,b:2}

      經(jīng) JSON.stringify(a)得到:

      “{“a”:1,"b":2}”
      熱門(mén)關(guān)鍵詞: Ajax請(qǐng)求 json數(shù)據(jù) 示例代碼

      您可能感興趣的相關(guān)文章:

      欄目列表
      推薦內(nèi)容
      熱點(diǎn)內(nèi)容
      展開(kāi)
      欧美一区二区三区免费A级视频,亚洲精品中文字幕综合,动漫精品中文字幕无码第一页,1024亚洲国产综合 亚太影院 柯西贝尔-游戏赚网
    1. <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
    2. <th id="l3qpx"><progress id="l3qpx"></progress></th>
        <th id="l3qpx"></th>
        <dd id="l3qpx"><font id="l3qpx"></font></dd>
        <th id="l3qpx"></th>