我在 Postman 中尝试了以下代码它正在工作。代码有问题吗?
$.ajax({
url: 'http://api.example.com/users/get',
type: 'POST',
headers: {
'name-api-key':'ewf45r4435trge',
},
data: {
'uid':36,
},
success: function(data) {
console.log(data);
}
});
我的控制台出现如下错误,请指教。
XMLHttpRequest cannot load http://api.example.com/users/get Response for preflight is invalid (redirect)
最佳答案
当我尝试调用 https 网络服务作为 http 网络服务时,我收到了同样的错误。
e.g when I call url 'http://api.example.com/users/get'
which should be 'https://api.example.com/users/get'
当您尝试调用 http 而不是 https 时,重定向状态 302 会产生此错误。
关于javascript - 为什么我的 $.ajax 显示 "preflight is invalid redirect error"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33645511/