Search Results

Search found 1 results on 1 pages for 'noobcoder'.

Page 1/1 | 1 

  • Getting jsonString via Jquery coming up empty

    - by NoobCoder
    I'm using asp mvc and I'm getting data in one part of my program like this public List<IncidentPerAreaCount> getIncident() { int RondeboschCounter = 0; int ClaremontCounter = 0; int AthloneCounter = 0; List<IncidentPerAreaCount> IncidentAreaCount = new List<IncidentPerAreaCount>(); IncidentPerAreaCount Rondebosch = new IncidentPerAreaCount(); IncidentPerAreaCount Claremont = new IncidentPerAreaCount(); IncidentPerAreaCount Athlone = new IncidentPerAreaCount(); List<Report> Reports = GetReports(); for (int i = 0; i < Reports.Count(); i++) { if (Reports.AsEnumerable().ElementAt(i).Area == "Rondebosch") { RondeboschCounter++; } else if (Reports.AsEnumerable().ElementAt(i).Area == "Claremont") { ClaremontCounter++; } else if (Reports.AsEnumerable().ElementAt(i).Area == "Athlone") { AthloneCounter++; } } Rondebosch.AreaName = "Rondebosch"; Rondebosch.NumberOfIncidents = RondeboschCounter; Claremont.AreaName = "Claremont"; Claremont.NumberOfIncidents = ClaremontCounter; Athlone.AreaName = "Athlone"; Athlone.NumberOfIncidents = AthloneCounter; IncidentAreaCount.Add(Rondebosch); IncidentAreaCount.Add(Claremont); IncidentAreaCount.Add(Athlone); return IncidentAreaCount; } Then I'm trying to get this string via Jquery var Reports = []; $.ajax({ url: "Home/getIncident", async: false, dataType: 'json', success: function (json) { Reports = json.whatever; } }); alert(Reports); However the alert function keeps coming up empty (ie empty textbox) instead of having a json formatted string with data. Please help...

    Read the article

1