I always wanted to do the secondment exercise with Ajax, so here we go;)
This is a complete plugin and should be installed in the wp-content/plugins/your-plugin-name folder. It consists of three files: the plugin itself, the Javascript file and the Ajax bootloader image.
Install the plugin and activate, and paste the following into the theme template file :
<?php if( class_exists( 'BRSFL_Chained_Selection' ) ) { // Parameters: ( $cat_id, $dropdown_text ) BRSFL_Chained_Selection::print_cats( 1, 'All Makes' ); } ?>
Also, configure two calls to wp_dropdown_categories as desired. See code comments for more details.
The drop-down list of subcategories has been changed in response to changes in the drop-down list of categories:

chained-categories.php
<?php add_action( 'plugins_loaded', array ( BRSFL_Chained_Selection::get_instance(), 'plugin_setup' ) ); class BRSFL_Chained_Selection { protected static $instance = NULL; public $plugin_url = ''; public $plugin_path = ''; public static function get_instance() { NULL === self::$instance and self::$instance = new self; return self::$instance; } public function plugin_setup() { $this->plugin_url = plugins_url( '/', __FILE__ ); $this->plugin_path = plugin_dir_path( __FILE__ ); $this->load_language( 'chainedselections' ); add_action( 'wp_enqueue_scripts', array( $this, 'script_enqueuer' ) ); add_action( 'wp_ajax_custom_query', array( $this, 'custom_query' ) ); add_action( 'wp_ajax_nopriv_custom_query', array( $this, 'custom_query' ) ); } public function __construct() {} public function script_enqueuer() { wp_register_script( 'ajax-quote' , plugin_dir_url( __FILE__ ) . '/ajax.js' , array( 'jquery' ) ); wp_enqueue_script( 'ajax-quote' ); wp_localize_script( 'ajax-quote' , 'wp_ajax' , array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) , 'ajaxnonce' => wp_create_nonce( 'ajax_chained_selection_validate' ) , 'icon' => plugin_dir_url( __FILE__ ) . '/ajax-loader.gif' ) ); } public function custom_query() {
ajax.js
jQuery( document ).ready( function( $ ) { var data = { action: 'custom_query', security: wp_ajax.ajaxnonce }; $( "#chained-categories" ).on( "change", function( e ) { // Add specific data to the variable, used to query the sub-categories data[ 'chained_subcat_id' ] = $( this ).val(); data[ 'chained_subcat_name' ] = $( '#chained-categories option[value=' + $( this ).val() + ']' ).text(); // A sub-category was selected if( $( this ).val() > 0 ) { // Ajax loader icon $( '#chained-subcontainer' ).html( '<img src="' + wp_ajax.icon + '">' ); // Ajax call $.post( wp_ajax.ajaxurl, data, // No error checking is being done with the response function( response ) { $( '#chained-subcontainer' ).html( response ); } ); } // No selection, show default else { $( '#chained-subcontainer' ).html( '<select name="chained-subcategories" id="chained-subcategories"><option value="">- Select a category first -</option></select>' ); } }); } );
Ajax-loader.gif
