gpt4 book ai didi

javascript - 如何在客户端获取 JSON 对象

转载 作者:行者123 更新时间:2023-11-30 15:21:43 24 4
gpt4 key购买 nike

我目前正在尝试将一个 JSON 对象从服务器发送到客户端,但我不确定我是否正确访问了它。

app.post('/url', function(request, response){
....
var result = fuse.search();

response.json(result); // results should be sent back as a response

} )

$.post("/url", options, function(response, request) {
var json = response.json;
)

最佳答案

https://api.jquery.com/jquery.post

jQuery.post( url [, data ] [, success ] [, dataType ] )

success

Type: Function( PlainObject data, String textStatus, jqXHR jqXHR )

A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case.

如果你进一步阅读

The success callback function is passed the returned data

这可能意味着你应该做的是

var json = response;

这当然假设您的请求确实确实收到了 JSON

关于javascript - 如何在客户端获取 JSON 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43637538/

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