我如何使用AJAX返回所有“;name”;值

How can I use AJAX to return all of the "name" values in my JSON file?

本文关键字:name 何使用 AJAX 返回      更新时间:2023-09-26

我有一个JSON文件,由九个完整的记录集组成,下面我列出了三个。

我的最终目标是将AJAX添加到网站中,我的json文件中的信息目前直接列在html中,而不是通过AJAX。我提取并构建了JSON文件,以便通过AJAX使用它。

我想了解我应该如何遍历每个json对象并返回列出的每个"名称"。

[{
   "name":"Keith Moore",
   "link":"http://www.moorelife.org/freedownloads-serieslist.php?",
   "image":"keith_moore.jpg",
   "details":"Teacher/Pastor, I refer to Keith as my '"bible college experience,'" he has 30+ years of free audio and video available on any and every subject."
 },
  {
   "name":"Kenneth Hagin",
   "link":"https://www.youtube.com/playlist?list=PLIXcY2izjpDgROo3MRlAU2MJSyjthXLLc",
   "image":"kenneth_hagin.jpg",
   "details":"Prophet, with nearly 70 years of ministry under his belt, Hagin most commonly preached on the subject of faith in Gods word."
 },
  {
   "name":"Bill Johnson",
   "link":"https://www.youtube.com/playlist?list=PLEtP4XPKdli585uNfIU8WNRYawCusmEYK",
   "image":"bill_johnson.jpg",
   "details":"Apostle/Pastor, Bill pastors a church in Redding California named Bethel Church, the church is most known for miracles, signs and wonders."
}]

到目前为止,这就是我所拥有的,但它还不够深入,无法访问名称值

$(document).ready(function() {  
  $.getJSON("data/asdf.json", function(result) {
    $.each(result, function(i, field) {
      $("#update").append(field + " ");
    });
  });
});

它向我的html报告了以下内容:

object对象

我正在寻找的是一个开始信息块,它将允许我开始为JSON文件中列出的每个值构建函数。

这行代码正在访问Object,而不是name属性。

$("#update").append(field + " ");

更改为:

$("#update").append(field.name + " ");