title: Set radio button checked with AJAX response
body: <p>I need to set a radio button in my form; it has to be checked with the values coming from an AJAX response. </p>
  
  <p>My AJAX response is <code>response.drive</code>. "Manual" or "Auto" could be its value. </p>
  
  <p><strong>UPDATE:</strong>
  So I tried it some different ways, but I couldn't figure this out. </p>
  
  <p>One way : </p>
  
  <pre><code>if(response.drive=="Manual") {
      .find('[name=drive]')[0].checked = true         
  } else {
      .find('[name=drive]')[1].checked = true
  }  
  </code></pre>
  
  <p>Another way:</p>
  
  <pre><code>.find("input:radio[name='drive'][value='"+ response.drive +"']")[0].checked = true.end()
  </code></pre>
  
  <p>This is how my ajax success function use to populate the form values. </p>
  
  <pre><code>.success(function(response) {
                      // Populate the form fields with the data returned from server
                      response = jQuery.parseJSON(response)
                      $('#editVehicle')
  
                              .find('[name="vehicle_id"]').val(response.vehicle_id).end()
                              .find('[name="vehicle_name"]').val(response.vehicle).end()
                              .find('[name="seats"]').val(response.seats).end()
                              .find('[name="luggage"]').val(response.luggage).end()
                              .find('[name="doors"]').val(response.doors).end()
                              .find('[name="emission"]').val(response.emission).end()
  
                              //.find('[name="drive"]').val(response.drive).prop("checked",true).end()
                              //.find('[name="aircon"]').val(response.aircon).prop("checked",true).end()
                              //.find("input:radio[name='drive'][value='"+ response.drive +"']")[0].checked = true.end()
  
                              //if(response.drive=="Manual"){
                  .find('[name=drive]')[0].prop('checked').end()
                              //}else{
                                  //.find('[name=drive]')[1].prop('checked')
                              //} 
  
                              .find('[name="rental"]').val(response.price).end();
  
                      // Show the dialog
  ---- -
  ---- 
  ---
  </code></pre>
  
  <p>This is HTML for radio button : </p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;label for=""&gt;Transmission :&lt;/label&gt;
      &lt;div class="col-sm-8"&gt;
          &lt;label class="radio-inline"&gt;
              &lt;input type="radio" name="drive" id="" value="1"&gt; Manual
          &lt;/label&gt;
          &lt;label class="radio-inline"&gt;
              &lt;input type="radio" name="drive" id="" value="2"&gt; Auto
          &lt;/label&gt;                                                                
      &lt;/div&gt;
  &lt;/div&gt;      
  </code></pre>
  
  <p>How can I do this correctly?</p>