gpt4 book ai didi

当 url 来自不同服务器时,jQuery.ajax 失败

转载 作者:行者123 更新时间:2023-12-03 22:17:40 24 4
gpt4 key购买 nike

如果您使用不同服务器的 URL,为什么 jQuery.ajax() 会抛出错误但没有错误消息?

最佳答案

这是因为浏览器中对 XMLHttpRequests 实现的跨域请求的限制。您可以通过使用 JSONP 作为格式来解决此问题,否则您将需要一个服务器端代理来处理该请求。

引自ajax documentationhttp://jquery.com

Note: All remote (not on the same domain) requests should be specified as GET when 'script' or 'jsonp' is the dataType (because it loads script using a DOM script tag). Ajax options that require an XMLHttpRequest object are not available for these requests. The complete and success functions are called on completion, but do not receive an XHR object; the beforeSend and dataFilter functions are not called.

关于当 url 来自不同服务器时,jQuery.ajax 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1201429/

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