Click here to Skip to main content
15,749,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Well i have the data returned from PHP which i then parse it. Data shows up for the attribute called empName but not for the nested ones. What is wrong that i need to correct in my javascript code. Heres the JSON string which returns from PHP (the output of variable called info):


And here' s the template (The data does not show for skill and level)

<script id="tmplEmpDetails" type="text/x-jsrender">
{{if data.length > 0}}
{{for data}}
    <td class="tg-spn1">{{}}</td>
    <td class="tg-spn1">{{}}</td>
    <td class="tg-spn1  ">{{}}</td>

The Javascript:

        $.post( "indexBase.php",
            var result = JSON.parse(info);                                                              
            $( "#tblEmpDetails tr[id!='hdrEmpDetails']" ).empty();
                    data : result

    $("#mainForm").submit( function() {                         
        return false;   


And finally the HTML (Sure i need to correct my HTML too)

<table class="tg" width="100%" id="tblEmpDetails">
<tr id="hdrEmpDetails">
    <th class="tg-s6z2" >Employee</th>
    <th class="tg-s6z2" >Skill</th>
    <th class="tg-s6z2" >Level</th>

Does that mean i have to for loop twice in my template?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900