我有一个网站多年,有一些表格可以登录等.最近我做了所有谷歌的AMP证明,但表格停止工作.我现在正在寻找几天,但我找不到合适的答案.
首先,我包含了所有必要的脚本和代码,就像在此页面上一样.之后,出现了第一个错误:"表单提交失败::响应必须包含AMP-Access-Control-Allow-Source-Origin标头".
然后我在页面中添加了标题.之后,第一个错误消失,但出现第二个错误:"表单提交失败::意外令牌<在位置0的JSON中".我在这里读过这个,但它对我来说没有真正的解决方案.
在这个阶段,我陷入了困境,我认为我走错了道路就像这样一个简单的形式.我只想回应一下输入......你能帮我吗?
亲切的问候,
帕特里克
<?php
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Origin: *.ampproject.org");
header("AMP-Access-Control-Allow-Source-Origin: https://www.domain.com");
header("Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin");
?>
<!doctype html>
<html amp>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="canonical" href="https://www.domain.com/test.php"/>
<title>AMP form</title>
</head> …Run Code Online (Sandbox Code Playgroud)