gpt4 book ai didi

javascript - 如何访问从 JQuery 收到的 JSON 响应中的数据?

转载 作者:行者123 更新时间:2023-11-30 10:14:03 25 4
gpt4 key购买 nike

<分区>

如何访问在 JQuery AJAX 请求的完整函数中返回的存储在 JSON 中的数据。例如,我有以下代码:

$.ajax({
url: 'buildings.php',
data: "building=" + building,
complete: function (response) {
alert(response.responseText);
alert(response.name);
}
});

在第一个警报中,它显示以下内容,这是我从 PHP 发送的预期 JSON 数据。

{"name":"HSB","description":"description","directionsURL":"directionsURL","imageArray":{"1":"URL 1","2":"URL 2"}}

在第二个警报中,它显示

undefined

如何访问我收到的显示在第一个警报中的数据?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com