Over a million developers have joined DZone.

getJSON on Drop Down Change Event

·

Simple jQuery getJSON request with call back to load drop down list control.

 

 

	function populateDropDown() {
	    
	    $.getJSON('/getData.aspx', { Name:$('#parm').val()}, function(data) {
	 
 	        var select = $('#DDLControl');
	        var options = select.attr('options');
	        $('option', select).remove();
	 
 	        $.each(data, function(index, array) {
	            options[options.length] = new Option(array['variety']);
	        });
	 
	    });
	 
	}
	 
	$(document).ready(function() {
	     
	    populateDropDown();
	    $('#DDLchangeData').change(function() {
	        populateDropDown();
	    });
	     
 	});
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}