title: Change Ajax Post parameters & returned HTML based on alternating dependant dropdowns
body: <p>I have 3 dropdowns containing values that are populated on page load</p>
  
  <pre><code>&lt;select class='form-control' id='make' placeholder='Make:'&gt;
  &lt;select class='form-control' id='model' placeholder='Model:'&gt;
  &lt;select class='form-control' id='version' placeholder='Version:'&gt;
  </code></pre>
  
  <p>I have a function that updates the values in the 'other' dropdowns that aren't clicked, based on the value of the dropdown that is clicked - but I have this function repeated 3 times, for each dropdown</p>
  
  <pre><code>$('#model').change(function(){
      let selectedModel = $(this).val();
      $.ajax({
          url: 'php/dropdown.php',
          type: 'POST',
          data: {model: selectedModel},
          success:function(data)
          {  $('#make').html('');
             $('#version').html('');
              let makeJSON = JSON.parse(data)[0];
              let versionJSON = JSON.parse(data)[2];
  
              for (let i = 0; i &lt; makeJSON.length; i++) {
                  if (makeJSON[i].mMake!= '' &amp;&amp; makeJSON[i].mMake!= null) {
                      $('#make').html($('#make').html() + '&lt;option value="' + makeJSON[i].mMake + '"&gt;' + makeJSON[i].mMake + '&lt;/option&gt;');
                  }
              }
  
              for (let i = 0; i &lt; versionJSON.length; i++) {
                  if (versionJSON[i].mVersion != '' &amp;&amp; versionJSON[i].mVersion != null) {
                      $('#version').html($('#version').html() + '&lt;option value="' + versionJSON[i].mVersion + '"&gt;' + versionJSON[i].mVersion + '&lt;/option&gt;');
                  }
              }
  
          }
      });
  });
  </code></pre>
  
  <p>And the PHP looks something like this:</p>
  
  <pre><code>$model = $_REQUEST['model'];
  
  $sqlupdateModel = "SELECT DISTINCT mMake, mVersion FROM Cars WHERE mModel = '$model';
  $stmtModel = sqlsrv_query( $conn, $sqlupdateModel);
  if( $stmtModel === false)
  {
      die( print_r( sqlsrv_errors(), true));
  }
  $updateModel = [];
  while( $row = sqlsrv_fetch_array( $stmtModel, SQLSRV_FETCH_ASSOC)){
      $updateModel[] = $row;
  }
  echo json_encode(array($updateMake, $updateModel, $updateVersion));
  </code></pre>
  
  <p>...and this all works fine,
  Basically, I'm looking for a simpler solution for reusing the function (both JS &amp; PHP) instead of rewriting it 3 times!</p>
  
  <p>In terms of what I have attempted, </p>
  
  <pre><code>$('#make, #model, #version').change(function(){
  let columnValue = $(this).val();
  .......
  data: {model: columnValue},
  success:function(data)
  {$(this).html(''); //this doesn't work obviously!
  </code></pre>
  
  <p>After this I'm snookered</p>