loop through json array jquery

前端 未结 3 1183
情书的邮戳
情书的邮戳 2020-12-08 00:21

I\'m trying to loop through this to get the \'name\' values. This is what I currently have, but it doesn\'t seem to be working, tried a few others from what was posted here

3条回答
  •  天涯浪人
    2020-12-08 01:09

    You have to parse the string as JSON (data[0] == "[" is an indication that data is actually a string, not an object):

    data = $.parseJSON(data);
    $.each(data, function(i, item) {
        alert(item);
    });
    

提交回复
热议问题