Schleid Alex

Schleid Alex

  • NA
  • 361
  • 44k

How to fill dependent dropdownlist with jquery

Apr 15 2021 7:35 PM
I am trying to acheive this simple thing I have class dropdownlist that upon selection will fill another student dropdownlist, I am using jquery, below is my code
 
  1.   $('#ddClass').on('change', function () {  
  2.         var ClassID = $('#ddlClass').val()  
  3.         $.ajax({  
  4.             url: 'StudentList',  
  5.             type: 'GET',  
  6.             contentType: 'apllication/html; charset=utf-8',  
  7.             data: { ID: ClassID},  
  8.             dataType: 'html',  
  9.             success: function (result) {  
  10.                $.each(result, function(index, row){  
  11. $('#ddlStudent).append("<option value = '"+row.StudentID+" '> "+row.StudentName+"</option>  
  12. }  
  13.             }  
  14.         }) 
 Please help me find out why it is not working.
 
Thank you!
 
 
 

Answers (3)