title: Retrieving JSON from PHP File, and Append inside div
body: <p>Im trying to do near real time graph update within my site. To do this im trying to basically reload a php file every 30 seconds. I made the data of PHP dynamically echo out json code as shown below. Ad inside the file is also <code>&lt;meta http-equiv="refresh" content="30"&gt;</code> which refreshes the file to recheck database.</p>
  
  <p><code>{"todayCalculateCR":"5%"}{"todayEPC":"0.20"}{"todayCTR":"34%"}{"yesterdayCalculateCR":"35%"}{"yesterdayEPC":"0.03"}{"yesterdayCTR":"24%"}{"monthCalculateCR":"14%"}{"monthEPC":"0.07"}{"monthCTR":"24%"}</code></p>
  
  <p>Basically now i want some jquery code to place on my index.php page to load this file, interpret the json code and append the data to the correct divs.</p>
  
  <p>Example:
  <code>&lt;div class="yesterdayEPC"&gt;0.03&lt;/div&gt;</code></p>
  
  <p>Ive been looking on jquery.com and on stack overflow for ways to basically take the above json data and append it.</p>
  
  <p><code>$.get( "dashboard-stats.php", function( data ) {
    $( "body" )
      .append( "yesterdayEPC: " + data.yesterdayEPC ) // John
      .append( "Time: " + data.yesterdayEPC ); //  2pm
  }, "json" );</code></p>
  
  <p>This is brief of PHP file making json:</p>
  
  <p><code>$month_visits = mysql_num_rows(mysql_query("SELECT * FROM</code>locker_reports<code>WHERE</code>uid<code>= '$user_id' AND</code>month<code>= '$month_date'"));
      $month_clicks = mysql_num_rows(mysql_query("SELECT * FROM</code>reports<code>WHERE</code>uid<code>= '$user_id' AND</code>month<code>= '$month_date' AND</code>status<code>= '1'"));
      $month_leads = mysql_num_rows(mysql_query("SELECT * FROM</code>reports<code>WHERE</code>uid<code>= '$user_id' AND</code>month<code>= '$month_date' AND</code>status<code>= '2'"));
      if($month_leads == "" || $month_clicks == "") 
      {
          echo json_encode(array("monthCalculateCR"=&gt;"n/a"));
          echo json_encode(array("monthEPC"=&gt;"n/a"));
      }
      else 
      {
          $monthCalculateCR = number_format($month_clicks / $month_leads)."%";
          echo json_encode(array("monthCalculateCR"=&gt;"".$monthCalculateCR.""));
          $monthEPC = number_format($month_leads / $month_clicks, 2)."";
          echo json_encode(array("monthEPC"=&gt;"".$monthEPC.""));
      }
      if($month_visits == "")
      {
          echo json_encode(array("monthCTR"=&gt;"n/a"));
      }
      else
      {
          $monthCTR = number_format($month_clicks / $month_visits, 2) * 100 . "%";
          echo json_encode(array("monthCTR"=&gt;"".$monthCTR.""));
      }</code></p>