c# - Jquery webservice foreach loop -
i'm trying jquery dropdownlist result set of webservice, getyears
function returning list of years 2013,2012,2011.... in list<string>
when bind ddlyears
values coming 1,2,3,4,5,6
$.ajax({ type: "post", url: "../webservice.asmx/getyears", data:"{}", contenttype: "application/json; charset=utf-8", datatype: "json", async: true, success: function (msg) { (var myvar in msg.d) { $('#ddlyears').append("<option value='" + myvar.tostring() + "'>" + myvar.tostring() + "</option>"); } }, error: function (jqerr) { errorcaller(jqerr); } });
try this:
success: function (msg) { $.each(msg.d, function (k, value) { $('#ddlyears').append("<option value='" + value + "'>" + value + "</option>"); }); }
Comments
Post a Comment