blind data in to dropdown

How to bind data into dropdown using jquery?

<script type=”text/javascript”>  

$(document).ready(function () {  

            $.ajax({                type: “POST”, url: “Index.aspx/GetCountriesName”, dataType: “json”, contentType: “application/json”, success: function (res)  

                {  

                   $.each(res.d, function (data, value) {                        $(“#ddlNationality”).append($(“<option></option>”).val(value.CountryId).html(value.CountryName));                     

 })                  

}   

});          

 })            

 </script> 

HTML:

<select id=”ddlNationality”><option value=”0″ >–Select Country–</option></select>

Leave a comment

Your email address will not be published. Required fields are marked *