php - API获取请求在邮递员中工作,但在jquery ajax中被CORS策略阻止
问题描述
AJAX 请求中的错误
http://localhost '已被 CORS 策略阻止:对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头
我的代码
var srv_url = 'https://api-domain.com/api/index.php?type=join&meetingID=test01&moderatorPW=mp&fullName=John';
var auth_token = 'e6a83f2844c9cdd4729b69dc851f96c1c073a23b4f37eb7cdec83bf8c9c7a06d'
$.ajax({
url: srv_url,
type: 'get',
beforeSend: function(xhr){
xhr.setRequestHeader("Authorization", auth_token);
},
success: function(res){
console.log(res)
},
error: function(e){
console.log(e)
}
})
但在邮递员工作
如果存在与 CORS 相关的问题,为什么此请求在同一台机器上的邮递员中工作。请帮助我,我在我的 ajax 代码中做错了什么。
解决方案
推荐阅读
- macos - OSX Catalina / OSX Tiger - 解决任何 ISO 问题
- java - 如何将 ChromeOptions 和 chrome Driver 声明为 blockBrowserNotification_Testng 的公共方法
- javascript - jQuery Ajax - 仍在重新加载页面 - Laravel 分页
- firebase - 从 Firestore 获取数据并渲染到另一个函数 DART
- git - Git:误导性错误:“找不到远程存储库”,而我没有写访问权限
- python - Python-Jupyter 中的键盘快捷键不起作用
- java - ListView.setAdapter(android.widget.ListAdapter)' 在空对象引用上
- shell - 如何在 aws cloudformation 模板中包含外部参数?
- firebase - Webpack 和 Firebase
- c++ - 为 Eigen 中的稀疏矩阵运算预分配内存