Hi there,
I and trying to create cascading dynamically loading dropdownlist in a custom wordpress plugin and cannot seem to get it working. Please see code below, any help would be greatly appreciated.

the console just returns "undefined", i am not sure if it is even running the php function?

here is the code:

jQuery Code in a separare js/scripts.js file.
jQuery(document).ready(function() {
var school=jQuery('#ddlSchool').val();
jQuery('#ddlResVisit').empty(); //remove all existing options
			type: 'POST',
			dataType: 'json',
			url: residential_visits.ajaxurl,
			data: {
				'action' : 'residential_visits',
				'school' : school
			complete: function( object ) {
				console.log(object.responseJSON.body );
				//if get correct data then deal with dropdownlist
In my plugin php file:
//Register and Enqueue my scripts
wp_register_script('ajax-script', plugins_url('js/jsscripts.js', __FILE__), array('jquery'),'1.1');

//localise the wordpress ajax file
wp_localize_script( 'ajax-script', 'residential_visits', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );

 // add the ajax actions for bothj logged in and non logged in users
add_action( 'wp_ajax_residential_visits', 'residential_visits');
add_action( 'wp_ajax_nopriv_residential_visits', 'residential_visits');

function residential_visits() {
    // Handle request then generate response using WP_Ajax_Response
$school = $_POST['ddlSchool'];
global $wpdb;
//SQL will have query at end school='$school'
$result = get_results("select id, group_name from wp_pods_residential_visits");

$main = array('data'=>$result);
echo json_encode($result); //return the data back.

// stop execution afterward.
Drop down CODE:
global $wpdb;
		  $schools = $wpdb->get_results("Select abbr_code, school_name from wp_pods_schools order by school_name;");
	      <label for"ddlSchools">School Attending:</label>
	      <select name="ddlSchool" id="ddlSchool">
			  foreach ($schools as $school){
	        <option value="<?php echo $school->abbr_code ?>"><?php echo $school->school_name ?></option>
	   <!-- Dropdown to be populated based upon previous selection. -->
   <select id="ddlResVisit" name="ddlResVisit">