title: Getting .done() of request from another function
body: <p>I have a form where I load the items of the select menu with ajax. But there is also an option which fills in all selects with the <code>change()</code> function. But since it needs to wait for the ajax request to be done I need to set an interval which would be different each time so I cannot use it that way.</p>
  
  <pre><code>window.setTimeout(function() {
    $("#car_brand").val(vehicle.brand).change();
  }, 100);
  </code></pre>
  
  <p>So this changes the value of <code>#car_brand</code> and car_brand loads all the options from the database when it gets changed. So if I don't set another interval it tries to change it without the new options being loaded. Is there a way to use the <code>.done()</code> of the ajax request here?</p>
  
  <p>Ajax request</p>
  
  <pre><code>function updateField(str, id, prevvalue, value, vehicletype){
      $.ajax({
          type: "get",
          url: "inc/ajax/form_rest.php",
          data: { q:str, prevvalue:prevvalue, value:value, vehicletype:vehicletype },
          success: function(html) {
                      $('#'+id).html(html);
                  }
          })
          .done(function(){
              $("#"+id).removeAttr("disabled");
          });
  }
  </code></pre>
  
  <p>Whole change function</p>
  
  <pre><code>function returnVehicleByValue(vehicleValue, vozila){
      $.get("inc/ajax/selectMojaVozila.php", 
          {vehicleValue:vehicleValue},
          function(html){
              var vehicle = html;
              //Select Moja Vozila
                  $("#"+vozila+"_year").val(vehicle.Year).change()
                  window.setTimeout(function() {
                      $("#"+vozila+"_brand").val(vehicle.Marke_vozila).change();
                  }, 100);
                  window.setTimeout(function() {
                      $("#"+vozila+"_model").val(vehicle.Model_vozila).change();
                  }, 350);
  
                  window.setTimeout(function() {
                      $("#"+vozila+"_type").val(vehicle.Tip_vozila).change();
                  }, 500);
                  window.setTimeout(function() {
                      $("#"+vozila+"_uitvoering").val(vehicle.izvedba_vozila).change();
                  }, 700);
          }, 'json'
      );
  }
  </code></pre>