Iterating thorough JSON with jQuery/Javascript

Posted by Aaron Salazar on Stack Overflow See other posts from Stack Overflow or by Aaron Salazar
Published on 2010-03-29T20:05:02Z Indexed on 2010/03/29 20:13 UTC
Read the original article Hit count: 334

Filed under:
|
|

I am trying to fill a table with JSON data. When I run the following script I get only the last entry of 10. I must have to do some sort of .append() or something. I've tried to put this in but it just returns nothing.

    $(function() {
        $('#ReportedIssue').change(function() {
            $.getJSON('/CurReport/GetUpdatedTableResults', function(json) {
                //alert(json.GetDocumentResults.length);
                for (var i = 0; i < json.GetDocumentResults.length; i++) {
                    $('#DocumentInfoTable').html(
                        "<tr>" +
                        "<td>" + json.GetDocumentResults[i].Document.DocumentId + "</td>" +
                        "<td>" + json.GetDocumentResults[i].Document.LanguageCode + "</td>" +
                        "<td>" + json.GetDocumentResults[i].ReportedIssue + "</td>" +
                        "<td>" + json.GetDocumentResults[i].PageNumber + "</td>" +
                        "</tr>"
                    )
                };

            });
        });

    });

Thank you,

Aaron

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery