Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate contact table from JSON file
    primarykey
    data
    text
    <p>I am new to JSON.</p> <p>I was doing a project on HTML, JSON and jQuery recently. Thing I want to achieve now is get data from the JSON file and load it into my table. The data was not loaded into my table.</p> <p>My json file contact.json</p> <pre><code>{ "length": 2, "info": [ { "name":"Sam", "email":"fred@server.com", "phone":"789456235" }, { "name":"Fred", "email":"fred@server.com", "phone":"125689564" } ] } </code></pre> <p>My script to load data:</p> <pre><code>window.onload = function () { var contacts; setTimeout(function(){ //pass it an anonymous function that calls foo loadData("contact"); },2000); }; function loadData(myfile){ $.getJSON( myfile + ".json", function(data){ console.log(data) $.each(data, function(index, element){ $.each(element, function(i, item){ $('#contacts').append('&lt;tr&gt;&lt;td&gt;' + item.name + '&lt;/td&gt;&lt;td&gt;'+ item.email +'&lt;/td&gt;&lt;td&gt;' + item.phone + '&lt;/td&gt;&lt;td&gt;'); }); }); }); } </code></pre> <p>My HTML</p> <pre><code>&lt;body&gt; &lt;div id="tt" class="easyui-tabs" style="width:400px;height:250px;"&gt; &lt;div title="Home"&gt; &lt;table id='contacts'&gt;&lt;/table&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p></p> <p>I copied the whole thing from <a href="https://stackoverflow.com/questions/10082929/create-contact-table-from-json-data">Create contact table from JSON data</a></p> <p>This is the error</p> <pre><code> TypeError: j is undefined http://code.jquery.com/jquery-1.4.4.min.js Line 32 </code></pre> <p>I'm getting the object in the console. but the data is not loaded. How do I fix this problem?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload