title: Jquery $.post to get data back in JSON format, can't iterate data properly?
body: <p>I'm building a web calendar application and I'm trying to add a feature that checks the db before sending a form to see if we can add the calendar event or not.</p>
  
  <p>Right now I have this script that try to get the response from a PHP file:</p>
  
  <pre><code>// send form data using ajax requests
  $.post(
      "addons/validate_event.php", 
      $("#modif_inventaire").serialize(), 
      function(response){      
  
          if (response) {
  
              var htmlresponse = "";
  
              $.each(response, function(key, value) { 
                htmlresponse += key + ': ' + value; 
              });
  
              alert(response)
              alert(htmlresponse)
          }
      }
  );
  </code></pre>
  
  <p>The response "addons/validate_event.php" will look like this: <code>{}</code> (empty == success) or like this:</p>
  
  <pre><code>{"20120106":[1300,1430,1510,"1600"],"20120107":["0900",1000,"1100","1200","1300","1400","1500"]}
  </code></pre>
  
  <p>Basically, I have a PHP script that check if we can add the event, if so, it returns an <code>empty</code> array. Otherwise, it returns an array containing <code>dates</code> in the format <code>yyyymmdd</code> and each date has an array of available <code>hours</code> in this format <code>hhmm</code>.</p>
  
  <p>But my problem is that when i try to iterate the array, <code>alert(response)</code> gives me the php answer <code>{"20120106":[1300,143 ....</code> but <code>alert(htmlresponse)</code> gives me this:</p>
  
  <p><code>0: {1: "2: 23: 04: 15: 26: 07: 18: 09: 310: "11: :12: [13: "14: 015: 916: 017: 018: "19: ,20: 121: 022: 423: 024: ,25: "26: 127: 128: 029: 030: "31: ,32: 133: 034: 235: 036: ,37: 138: 139: 040: 541: ,42: 143: 044: 245: 546: ,47: 148: 149: 150: 051: ,52: 153: 054: 355: 056: ,57: 158: 159: 160: 561: ,62: 163: 064: 365: 566: ,67:......</code></p>
  
  <p>What am I missing? </p>
  
  <p>Thanks a lot</p>
  
  <p>Joel</p>