dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Need to extract data from json file using javascript.

  1. #1
    Join Date
    May 2015
    Posts
    14

    Exclamation Need to extract data from json file using javascript.

    Help i want to extract data of the DATAPOINTS OF THE 4TH RESULT in the json file.I want the output tin html.
    The piece of code that i have written is nt working.Pls help

    html code
    Code:
    <html>
    <head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
    
    <script>
    
        $(function() {
    
    
       var people = [];
    
       $.getJSON('people.json', function(data) {
           $.each(data.results[3].dataPoints, function(i, f) {
              var tblRow = "<tr>" + "<td>" + f.heartRate + "</td>" +
               "<td>" + f.timeFromStart + "</td>"  + "</tr>"
               $(tblRow).appendTo("#userdata tbody");
         });
    
       });
    
    });
    </script>
    </head>
    
    <body>
    
    <div class="wrapper">
    <div class="profile">
       <table id= "userdata" border="2">
      <thead>
                <th>heartRate</th>
                <th>time</th>
             
            </thead>
          <tbody>
    
           </tbody>
       </table>
    
    </div>
    </div>
    
    </body>
    </html>
    AND THE FOLLOWING IS THE JSON FILE ISS ATTACHED.
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2007
    Posts
    503
    Works fine for me...

    The first few lines of the table look like:
    Code:
    <thead>
    <tbody>
    <tr>
    <td>84</td>
    <td>0.53</td>
    </tr>
    <tr>
    <td>84</td>
    <td>1.56</td>
    </tr>
    <tr>
    <td>83</td>
    <td>2.53</td>
    </tr>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles