我的网站上有一个表单,应该将文本字段“电子邮件”写入谷歌电子表格。提交表单时,它会调用一个函数,该函数将 jquery ~ v 1.4 ajax POST 发送到谷歌文档。(我已经测试了谷歌表单并且它有效)
我遇到了 CORS 错误。
跨域请求被阻止:同源策略不允许在https://docs.google.com/forms/ **********************读取远程资源 **************************** /formResponse. 这可以通过将资源移动到同一域或启用 CORS 来解决。
我的阿贾克斯是
$scope.storeEmail = function() {
var email = $scope.fA.email;
$.ajax({type: "POST",
async: true,
url: 'https://docs.google.com/forms/***************************/formResponse',
data: { field_key : email, submit : "Submit"},
success: function(resp) {
// give success feedback and redirect page
}
error: function(xhr, statusText, error){
console.log(xhr);
}
};
Run Code Online (Sandbox Code Playgroud)
我试过 向 ajax 请求添加凭据和标头
withCredentials: …Run Code Online (Sandbox Code Playgroud)