title: Adding options to a dynamically loaded select
body: <p>Which is the best way to add <code>&lt;option&gt;...&lt;/option&gt;</code> to a select that has been dynamically added to the dom?</p>
  
  <p>I mean at a generic <code>&lt;select&gt;</code> that has been added subsequently an ajax call. I would like to add the option before showing the select element.</p>
  
  <p>thanks!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is the function that I have </p>
  
  <pre><code>$.ajax({
      type: "get",
      url: baseUrl + 'MyService.asmx/NewReferent',
      data: JSON.stringify({}),
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function (msg) {
          // Get the referent item from the webservice
          var referent = msg.d;
          // Render the template with the Referent data
          var referentTemplate = $("#referentTemplate").tmpl(referent);
          //add button style
          $(".button", referentTemplate).button();
          //Show the Dialog
          $("#referent-dialog").empty().html(referentTemplate).dialog('open');
      }
  }); 
  </code></pre>
  
  <p>This is the code that I have to get the options from the server</p>
  
  <pre><code>$.getJson(baseUrl + 'MyService.asmx/GetReferentTypes', function (data) {
      $.each(data, function (key, value) {
          $('#select_id').append($("&lt;option&gt;&lt;/option&gt;").attr("value", key).text(value));
      });
  });
  </code></pre>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>Unfortunately I am not able to understand what's going on with my code. With some little modification to the code of @Raynos I have been able to receive the following JSON data from the server</p>
  
  <pre><code>{"d":
      [
          {"__type":"Full.Namespace.Path.ReferentType","ReferentTypeID":1,"Description":"option1"},
          {"__type":"Full.Namespace.Path.ReferentType","ReferentTypeID":2,"Description":"option2"}
      ]
  }
  </code></pre>
  
  <p>that is not parsed correctly from my <code>$.each()</code> function call. I have two question now:</p>
  
  <ul>
  <li>Who's going to add the _type parameter?</li>
  <li>How can I correct the parsing <code>each()</code>?</li>
  </ul>