gpt4 book ai didi

javascript - 无法从本地主机向远程服务器发出 ajax 请求

转载 作者:行者123 更新时间:2023-12-01 02:37:12 24 4
gpt4 key购买 nike

我正在从本地服务器向远程页面(我是管理员)发出ajax请求(使用jquery),然后我得到了

 No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://ica.local.com' is therefore not allowed access. The response had HTTP status code 405.

这就是我的请求:

$.ajax({
url: myurl,
type: "POST",
// This is the important part
xhrFields: {
withCredentials: true
},
// This is the important part
success: function (response) {
// handle the response
},
error: function (xhr, status) {
// handle errors
}
});

远程服务器上的应用程序正在 nginx 服务器上运行。我尝试将nginx的conf文件更改为Access-Control-Allow-Origin: * 但还是不行。

最佳答案

这是因为两台机器位于不同的服务器上。出于开发目的,您可以使用现有的 Chrome 扩展来解决此问题。

只需在 Chrome 扩展页面上搜索“跨源问题”,然后添加其中一个扩展

关于javascript - 无法从本地主机向远程服务器发出 ajax 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47819273/

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