loop through json array jquery

前端 未结 3 1176
情书的邮戳
情书的邮戳 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:14

    you could also change from the .get() method to the .getJSON() method, jQuery will then parse the string returned as data to a javascript object and/or array that you can then reference like any other javascript object/array.

    using your code above, if you changed .get to .getJSON, you should get an alert of [object Object] for each element in the array. If you changed the alert to alert(item.name) you will get the names.

提交回复
热议问题