title: properly encode and decode json results (php to js)
body: <p>I am trying to encode my array results to json and pass them to a ajax successful event in javascript.</p>
  
  <pre><code>PHP
  
      $results = array(
          "time1" =&gt; 1,
          "time2" =&gt; 2,
  
      );
      echo json_encode($results); 
  </code></pre>
  
  <p>JAVASCRIPT / JQUERY</p>
  
  <pre><code>   $.ajax({
               type: "POST",
               url: "actions/myphp.php",
               data: PassArray,
               dataType: 'json',
               beforeSend: function (html) { // this happens before actual call
               //    alert(html);
               },
               success: function (html) { 
                   // $("#loginoutcome").text(html);
                  // alert(html);
                   var obj  = jQuery.parseJSON(html ); 
                  // Now the two will work
                  $.each(obj, function(key, value) {
                      alert(key + ' ' + value);
                  });
  
               },
  </code></pre>
  
  <p>Leaving the JQUERY.parseJSON there throws a json parse unexpected character, I dont think I that I need it anyway as I specify in the dataType: 'json', above?.. 
  But how can I retrieve the values ??</p>
  
  <p>Thanks</p>