JQuery - Iterating JSON Response

前端 未结 3 649
温柔的废话
温柔的废话 2021-01-25 16:38

The Story So far....

Trying to learn JS and JQuery and i thought i would start with the basics and try alittle AJAX \"search as you type\" magi

3条回答
  •  遇见更好的自我
    2021-01-25 16:50

    Your code:

    $.each(JSONData, function(i, item) {
        var li = $('
  • ').append(i).appendTo('ul#live-list'); });
  • Says "iterate over the keys and values of the outer JSON structure, and print the keys". The first key is "AccountNumber", so you end up printing that.

    What you want to do is iterate over the array stored at JSONData.AccountNumber, and print the values:

    $.each(JSONData.AccountNumber, function() {
        var li = $('
  • ').append(this).appendTo('ul#live-list'); });
提交回复
热议问题