jQuery implements the method of getting json data when selecting the drop down list

  • 2020-05-30 19:20:30
  • OfStack

This article demonstrates an example of how jQuery implements the method of getting json data when selecting a drop-down list. Share with you for your reference. The details are as follows:


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();
 });
});

I hope this article has been helpful to your jQuery programming.


Related articles: