This is my JSON data.
[ {"CountyId":2,"Name":"Snohomish","StateId":1,"State":null,"Plans":null}, {"CountyId":1,"Name":"Whatcom","StateId":1,"State":null,"Plans":null} ]
I am trying to populate UL on my webpage with this data.
function loadSavedCounties() { $.post("/Plans/GetPlanCounties/", { planId: $("#PlanId").val() }, function (data) { populateSavedCounties($("#SavedCounties"), data); } ); } function populateSavedCounties(select, data) { select.html(''); var items = []; $.each(data, function (id, option) { items.push('<li>' + option.Name + '</li>'); }); select.append(items.join('')); }
I know that I successfully call loadSavedQueries() because my UL is cleared when select.html('') called. But no items are returned to UL.
Updating ...
After explicit fixes and changes did not work, I found a problem in the controller that did not throw an error, but basically returned empty JSON objects. Once I caught this, the data started to flow down, and the proposed changes did the trick.
source share