title: How to display json array as repeating region from query
body: <p>Currently all working with my jquery $.post actions, successful connections, query and json_encode return to my page.  What I'm unable to do(and new to json) is how to display the returned values as a live feed?  My current jquery js file is 'jquery-1.7.2.min.js' and my code is</p>
  
  <pre><code>    $(document).ready(function(){
        setInterval(function(){
        $.post('query.php', function(pendingReq){
        $('#div_id').html(pendingReq);
        }), 'json' });
      }, 5000
  
  );
  </code></pre>
  
  <p>pendingReq is my returned data from the query and the current output looks like:
  <code>{"[0]":"FirstReq", "[1]":"SecondReq", ...."}</code> based upon my mysql query build of the array</p>
  
  <pre><code>$res = array("[0]"=&gt;var['1']...);
  </code></pre>
  
  <p>I am very new to using json, and don't use a lot of javascript, but would like to have the returned data show up in a table, thank you.</p>
  
  <p>My code below works, but for only one row of the mysql query, if two entries exist I get a "Uncaught SyntaxError: Unexpected token {" error in Firebug??  Still returning results as before:</p>
  
  <pre><code>    $res = array("req_name"=&gt;$ew_display['req_name'], "date"=&gt;$ew_display['req_dt']);
  echo json_encode($res);
  
  
  
  $(document).ready(function(){
              var table_template = "&lt;table border=1 cellspacing=0 id='results'&gt;&lt;tr&gt;&lt;th&gt;JTAR #&lt;/th&gt;&lt;th&gt;JTAR @&lt;/th&gt;&lt;/tr&gt;&lt;/table&gt;";
              $("#testd").html(table_template);
      setInterval(function(){
          $.post("query.php", {track : 2}, function(pendingReq){
              var json = JSON.parse(pendingReq);
              var template = "&lt;tr&gt;&lt;td&gt;{{req_name}}&lt;/td&gt;&lt;td&gt;{{date}}&lt;/td&gt;&lt;/tr&gt;";
              var new_row = Mustache.render(template, json); 
              $("#results").append(new_row).fadeIn("slow");
          }), "json"
  }, 5000);
  </code></pre>