简体   繁体   中英

How to create HTML table for the JSON data dynamically?

I want to extract only specific data from a "JSON" array. so far i have tried doing this,please help me out.

<?php
$uri=$_POST['uri'];
$api_key=$_POST['api_key'];
$board=$uri.$api_key;
$value=file_get_contents($board);
$json_o=(array)json_decode($value);
//echo "<pre>";
print_r($json_o);//here is the result of request 
//echo "</pre>";
    ?>

to fetch "uri"-It references the ".js" page

$("#btn2").click(function(event){
$.post( 
             "main.php",{api_key:"024b427a5d41a62",uri:"https://kanbanflow.com//v1/tasks?apiToken="},
             function(data) {
             $('#content').html(data);
             }
          );
});

Loop over the data using each() and construct the html

function(data){
 var myTable=$('#myTable');
  $(data).each(function(index,obj){
   // prepare TR & TDs for each row and append to myTable     
  })    
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM