dtlygweb2017 2011-04-25 14:42
浏览 28
已采纳

使用json值填充html表

I have an table.html, data.php and json.csv within the same folder.

data.php is doing fopen("json.csv","r") to read from json.csv.

How can I display the json objects as a table within table.html?

    <html>
    <head>
    <script type="text/javascript" src="jquery.js">
    function display(){
  $.post('data.php',function(data){
     $("#txtJSON").html(data); 
  });
    }

   </script>
   </head>
   <body onload="display()">
   <table id="#jobtable">
   <input type="text" id="txtJSON" />
   </table>
   </body>
   </html>
  • 写回答

3条回答 默认 最新

  • doujin4031 2011-04-25 16:08
    关注

    psuedocode

    php

    Take the data read in from doing the fopen.
    create a php array (a1)
    create a php array (a2)
    split it on new lines 
    iterate through all of those lines
      clear (a2)
      split the current line on commas (or w/e separator)
        insert each element into a2
      insert a2 into a1
    
    return a json_encode(a1)
    

    html

    do a jQuery.parseJSON(returned data from php) http://api.jquery.com/jQuery.parseJSON/
    iterate through the datastructure adding a new html row for every row in the structure...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化