使用JSON的Javascript响应包装器

人气:520 发布:2022-09-22 标签: html javascript api json

问题描述

大家好, 我只需要使用JSON包装器捕获响应并在JSON文档中正确查看,一旦我点击按钮。 (你知道我们可以使用JSON编辑器来完成这项工作,但涉及复制/粘贴,我不希望这样) 以下是代码的一部分 - >> <!DOCTYPE html> < html> ; < title> API集成测试显示活动Droplet< / title> < head> < / head> < body>

API集成测试1 - 显示活动Droplet


Regds Kashif

Regds Kashif

推荐答案

我喜欢JSON API,但没有代理,我无法通过跨域Javascript进行API调用。通过添加可选的回调参数来包装JSON响应,可以很容易地解决这个问题。调用/ someMethod?api_key = ...& callback = myCallback会返回: myCallback({response:...}) 你说什么? 更多细节你可以访问 link [ ^ ]。它可能对您有所帮助。 I love the JSON API, but without a proxy, I'm unable to make API calls via cross-domain Javascript. This is easily fixed with the addition of an optional callback parameter to wrap the JSON response. A call to /someMethod?api_key=…&callback=myCallback would return: myCallback({"response": … }) What say you? Further more details you can visit this link[^]. It might be helpful to you.

472