该代码已经在几天前生效,并且停止了将自定义网络表单发布到Google表单的工作。
function postContactToGoogle() {
var nombre = $('#nombre').val();
var email = $('#email').val();
var celular = $('#celular').val();
var localidad = $('#localidad').val();
var consulta = $('#consulta').val();
var landingurl = window.location.href;
$.ajax({
url: "https://docs.google.com/forms/d/e/1FkIpQLSctnqei_9dHoTWu-OZo368YarObkIbtdVqlZj7nzufXmJL43w/formResponse",
data: {
"entry_14395183": nombre,
"entry_1841864308": email,
"entry_1155940989": celular,
"entry_1563742": localidad,
"entry_606503689": consulta,
"entry_1196074333": landingurl
},
type: "POST",
dataType: "xml",
statusCode: {
0: function() {
window.location.replace("gracias.html");
},
200: function() {
window.location.replace("gracias.html");
}
}
});
}
控制台出现以下错误,并且Web表单数据未发布。代码有什么问题?
控制台显示错误:
VM497 pageserver.page2.es5.521962b3e9a2762cf449.bundle.js:1 POST https://docs.google.com/forms/d/e/1FAIpQLSctnqei_9dHoTWu-OZo368YarObkIbtdVqlZj7nzufXmJL43w/formResponse net :: ERR_ABORTED 401 发送@ VM497 pageserver.page2.es5.521962b3e9a2762cf449.bundle.js:1 ajax @ VM497 pageserver.page2.es5.521962b3e9a2762cf449.bundle.js:1 postContactToGoogle @(索引):114 onclick @(索引):2408 (索引):1 CORS策略已阻止从源“ https://docs.google.com/forms/d/e/1FAIpQLSctnqei_9dHoTWu-OZo368YarObkIbtdVqlZj7nzufXmJL43w/formResponse”访问“ https://9qzvid0lti5au5spz1ss8q-on.drv.tw”处的XMLHttpRequest:请求的资源上不存在“ Access-Control-Allow-Origin”标头。