title: Jquery ajax populate dropdown with json response data
body: <p>I know there are quite a few questions floating on this but I'm still not sure what to do. </p>
  
  <p>I have a HTML form called "CuisineForm", after the user selects the type of cuisine, the AJAX sends the form to the server. The AJAX call works fine, and server responds with a JSON responsewhich contains all the serving times of this particular cuisine. These serving times are divided into Breakfast, Lunch and Dinner. </p>
  
  <p><strong>These times need to be populated into 3 separate dropdowns in the same form. but I don't really know how to process the JSON results to populate the 3 dropdowns in the form.</strong></p>
  
  <p>Here is the JSON response from the PHP server side script. 
  Note that this was generated in the PHP script using "echo json_encode()".</p>
  
  <pre><code>{"breakfast":[{"09:00:00":"9:00 am"},{"09:30:00":"9:30 am"}],"lunch":[{"12:00:00":"12:00 pm"},{"12:30:00":"12:30 pm"}],"dinner":[{"19:00:00":"7:00 pm"},{"19:30:00":"7:30 pm"}]}
  </code></pre>
  
  <p>Here is my $.post code.</p>
  
  <pre><code>$.post( "gettimeslots", $( "#CuisineForm" ).serialize(), function() {
            alert( "success" );
          })
            .done(function(data) {
              // Not sure what code to write here to populate dropdown
  
            })
            .fail(function() {
              alert( "There was a problem getting the dropdown values!" );
            })
            .always(function() {
              alert( "always" );
          });
  </code></pre>
  
  <p>Here is my dropdown that I want to populate</p>
  
  <pre><code>&lt;select name="breakfasttimes" id="breakfasttimes"&gt;&lt;/select&gt;
  &lt;select name="lunchtimes" id="lunchtimes"&gt;&lt;/select&gt;
  &lt;select name="dinnertimes" id="dinnertimes"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>Most implementations tend to use $.getJSON. But as shown above I am using $.post instead. Please tell me if I should use $.getJSON instead.</p>
  
  <p>Can someone offer some pointers or code advice?</p>
  
  <p>Thanks
  Kevin</p>