gpt4 book ai didi

json - 差异 : JSONP vs GET

转载 作者:可可西里 更新时间:2023-11-01 17:36:26 24 4
gpt4 key购买 nike

这是我的问题,这些请求之间有什么区别?

我在尝试执行 get 请求时遇到问题,出现错误

XMLHttpRequest cannot load http://urbanetradio.com/wp-json/posts. The 'Access-Control-Allow-Origin' header has a value 'http://localhost:8100' that is not equal to the supplied origin. Origin 'http://run.plnkr.co' is therefore not allowed access.

get 请求指向 my-site-url/wp-json/posts,这是一个 WordPress 帐户。和 this is the method I am using

所以,有人说,使用 jsonp 而不是 get,但为什么呢?

最佳答案

Jsonp 用于支持跨源资源共享的 Web API。下面这篇文章举例说明了如何发起支持cors的请求。如果 webapi 未配置为允许来自您的主机的请求,您可能无法在不更改 api 的情况下使其工作。

支持cors的网络请求: http://www.html5rocks.com/en/tutorials/cors/

设置一个使用 cors 的 web api: http://mobile.codeguru.com/csharp/.net/net_asp/using-cross-origin-resource-sharing-cors-in-asp.net-web-api.html

关于json - 差异 : JSONP vs GET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30197436/

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