0

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

1
  • Can you post the actual json that you are getting back? My guess is that you aren't getting a json array. Commented Mar 29, 2010 at 20:09

1 Answer 1

2

Your code has the following:

$('#DocumentInfoTable').html(...);

which replaces the html content every time you call it. Try replacing that with:

$('#DocumentInfoTable').append(...);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.