gpt4 book ai didi

javascript - 为什么在浏览器上调用 API 没有返回回调

转载 作者:行者123 更新时间:2023-12-02 23:13:07 25 4
gpt4 key购买 nike

我正在 Chrome 浏览器中运行此脚本

https://apis.google.com/js/client.js?callback=cb

我没有得到我指定的回调方法?

这仅适用于脚本标签吗?我不能直接在浏览器上加载并查看结果吗?

如有任何帮助,我们将不胜感激

最佳答案

我不确定您期望看到什么或期望发生什么,但您可以在浏览器中看到 JSON-P 回调的结果。

如果我输入此网址:

https://skyviewcafe.com/atlas/?q=Tirana&callback=foo

我在 Chrome 中得到以下输出:

/**/ typeof foo === 'function' && foo({"originalSearch":"Tirana","normalizedSearch":"TIRANA","matches":[{"matchedByAlternateName":false,"matchedBySound":false,"city":"Tirana","county":"","state":"Tiranë","country":"ALB","longCountry":"Albania","flagCode":"al","latitude":41.3275,"longitude":19.8189,"elevation":0,"zone":"Europe/Tirane","zip":"","rank":5,"placeType":"P.PPLC","source":2,"displayName":"Tirana, ALB (Albania)","zoneOffset":60,"zoneDst":60},{"matchedByAlternateName":false,"matchedBySound":false,"city":"Tiranagama","county":"","state":"","country":"LKA","longCountry":"Sri Lanka","flagCode":"lk","latitude":6.1333,"longitude":80.1167,"elevation":0,"zone":"Asia/Colombo","zip":"80244","rank":2,"placeType":"P.PPL","source":1,"displayName":"Tiranagama, LKA (Sri Lanka)","zoneOffset":330,"zoneDst":0}],"time":8.630123138427734,"count":2});

您可以清楚地看到返回的 JSON 如何包装在对指定回调函数 foo 的调用中。

关于javascript - 为什么在浏览器上调用 API 没有返回回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57264196/

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