<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title> </title> <script src="../Scripts/jquery-2.0.2.js"></script> <script type="text/javascript"> $(document).ready(function () { debugger; getCountryList(); // $('#ddlCountry').html(); }); function getCountryList() { $.ajax({ url: "DDLFillWithJSON.aspx/GetCountryList", type: "GET", contentType: "application/json; charset=utf-8", dataType: "json", success: onSuccess, error: geterror, failure: function (response) { alert(response.d); }, async : false }); } function onSuccess(response) { debugger; var myobject = eval(response.d); BuildList(myobject); } function BuildList(msg) { debugger; var select = ''; for (var i = 0; i < msg.length; i++) { select += '<option value=' + msg[i].MId + '>' + msg[i].MasterName + '</option>' + '' } var newselect = select; $('#ddlCountry').html(select); return false; } function geterror(xhr, ajaxOptions, thrownError) { alert(xhr.status + '</br>' + xhr.responseText + '</br>' + thrownError); } </script> </head> <body> <form name="form1" method="post" action="DDLFillWithJSON.aspx" id="form1"> <div> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTI5ODc2OTIxM2RkTGlfCS5dXlZC1iQLAsR2qKqwjOs=" /> </div> <div> <select name="ddlCountry" id="ddlCountry"> </select> </div> </form> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)