如何解决如何使用 XMLHttpRequest 提交 Pardot 表单处理程序?
我很困惑,为什么pardot不允许这样的AJAX请求?它们不是更用户友好的功能吗?
我正在尝试添加一个表单处理程序并尝试使用它,并且当我保留 pardot 表单处理程序的默认提交时它可以工作。 (一个简单的点击页面重定向到成功网址,否则到错误网址)
当我尝试使用 XMLHttpRequest
执行此操作时,出现此错误:
index.html:1 Access to XMLHttpRequest at 'http://go.pardot.com/my-long-url-here' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
这是我的代码:
var xhr = new XMLHttpRequest();
xhr.open("POST",'http://go.pardot.com/l/903091/2021-02-05/4cqj',true);
xhr.setRequestHeader("Access-Control-Allow-Origin","*");
//Send the proper header information along with the request
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xhr.onreadystatechange = function () { // Call a function when the state changes.
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
// Request finished. Do processing here.
} else {
alert("error of course")
}
}
xhr.send("email=taoufiq@gmail.com");
// xhr.send(new Int8Array());
// xhr.send(document);
表单只有一个简单的电子邮件。
有没有办法用 AJAX 实现这个功能?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。