DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Mike has posted 1 posts at DZone. View Full User Profile

getJSON on Drop Down Change Event

08.28.2012
| 6117 views |
  • submit to reddit
	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();
	    });
	     
 	});

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