0
我想通过AJAX请求将数据发送到Google表单。通过AJAX向Google表单发送数据
我已经设置了一个Google表单,当它从直接链接中使用时它工作正常。
然而,当我加载页面如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Hello Google Forms</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js">
</script>
<script>
// entry ids
var entry_id_email = "entry.XXX";
var entry_id_name = "entry.XXX";
// data to be sent
var data = {};
data[entry_id_email] = "[email protected]";
data[entry_id_name] = "Foo Bar";
// form key
var form_key = "XXX";
// url
var url = "https://docs.google.com/forms/d/" + form_key + "/formResponse";
// ajax request
$.ajax({
url: url,
data: data,
type: "POST",
dataType: "xml",
});
</script>
</body>
</html>
我得到以下错误:
XMLHttpRequest cannot load https://docs.google.com/forms/d/XXX.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://myorigin' is therefore not allowed access.
请检查这个https://wiki.base22.com/pages/viewpage.action?pageId=72942000 –
这是我正在遵循的教程。我应该改变什么,特别是在我的代码示例中,以使其工作? – SeanPlusPlus