【发布时间】:2016-09-13 10:06:31
【问题描述】:
我正在尝试使用 Web to Lead html 代码将联系我们表单详细信息发送到 Insightly CRM。我在我的functions.php中使用以下代码更改了表单的操作url:
add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');
function wpcf7_custom_form_action_url($url) {
global $post;
$id_to_change = 1315;
if($post->ID === $id_to_change)
return 'https://xxxx.insight.ly/WebToLead/Create';
else
return $url;
}
inspector 看起来一切正常,但提交时出现以下错误:
XMLHttpRequest cannot load https://xxxx.insight.ly/WebToLead/Create. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://xxxx.com' is therefore not allowed access.
我尝试将此添加到我的functions.php:
add_action( 'init', 'allow_origin' );
function allow_origin() {
header("Access-Control-Allow-Origin: *");
}
我尝试在 theme.php 中添加这个:
header("Access-Control-Allow-Origin: *");
我尝试将此添加到联系表单 7 插件的 scripts.js 中:
$.ajax({
url: url,
++headers: { 'Access-Control-Allow-Origin': '*' },
++crossDomain: true,
我尝试将其添加到 .htaccess:
Header always set Access-Control-Allow-Origin "*"
没有任何作用:( 我的服务器有 Varnish 4 和 ConfigServer Security & Firewall,但我禁用了这两者,仍然得到同样的错误。 请帮帮我:(
【问题讨论】:
标签: cross-domain contact-form-7 insightly