从localhost使用谷歌联系人api创建联系人时出现CORS错误
CORS error on creating contact with google contacts api from localhost
我在请求时收到Cross-Origin Request Blocked:
错误,代码如下。
$.ajax({
url: 'https://www.google.com/m8/feeds/contacts/default/full?access_token=' + token.access_token,
type: 'POST',
crossOrigin: true,
crossDomain: true,
Origin: 'http://localhost',
Host: 'www.google.com',
xhrFields: {
withCredentials: true
},
dataType: 'xml',
'Gdata-version': '3.0',
'Content-Type': 'application/atom+xml',
'body': xml,
}).done(function(data) {
console.log(data);
});
});
GET
方法以jsonp(不适用于POST
方法)作为数据类型检索联系人,没有任何错误,但在POST
方法中我得到了错误。
很容易,您应该首先设置serverhttp响应头。这与您的前端javascript代码无关。您需要返回此标题:
Access-Control-Allow-Origin:*
或
Access-Control-Allow-Origin:your domain
相关文章:
- Node.js v6.2.0类扩展不是函数错误
- Jquery菜单操作不稳定,定位不正确,存在一般错误
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 试图在引导模式内动态生成图表,得到offsetWidth错误
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 我如何修复包含在captcha的addthis中的错误
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- 节点是否需要模块传递带有方括号的arg?这是个错误吗
- Webpack/Rect:遵循egghead.io教程,但出现错误:您可能需要一个合适的加载程序来处理此文件类型
- PHP&jQuery联系人表单错误
- Docusign / Salesforce:从 Salesforce 自定义对象发送信封会给出错误消息“记录中没有联系人
- 从localhost使用谷歌联系人api创建联系人时出现CORS错误
- 联系人表单的AJAX POST返回500错误
- 在用户登录时访问谷歌联系人会抛出Meteor.bindEnvironment错误.我对纤维的理解有什么问题?
- 联系人表单提交返回500错误
- Php联系人表单引用错误
- Google联系人API错误:通过脚本加载请求超时.可能的原因:源URL不正确;提要需要身份验证
- 使用 jquery get 导入 gmail 联系人时(“未捕获的类型错误:无法读取未定义的属性'0')
- 联系人信息列表不返回“错误”,即使它返回信息
- 使用选择元素的Ajax联系人表单错误