gpt4 book ai didi

go - AMP 表单始终显示提交错误,即使响应代码为 200

转载 作者:IT王子 更新时间:2023-10-29 02:20:18 26 4
gpt4 key购买 nike

我正在使用 AMP 表单将数据发送到我的 Golang 服务器。即使我跳过所有已发送数据的处理,只是按照 AMP 表单引用中所述使用代码 200 编写响应,我仍然会看到提交错误模板。

这是我的表格(我跳过了这些字段,因为它太长了)

<form action-xhr="/contactus" method="POST" class="contactForm" target="_top" custom-validation-reporting="show-all-on-submit" id="contactForm">
<fieldset>
<!-- divs with input and submit button -->
</fieldset>
<div submit-success>
<template type="amp-mustache">
Success!
</template>
</div>
<div submit-error>
<template type="amp-mustache">
Error!
</template>
</div>
</form>

这是服务器响应的示例:

HTTP/1.1 200 OK
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Sun, 23 Sep 2018 21:48:15 GMT
Content-Length: 23
Content-Type: application/x-gzip

问题可能出在服务器端吗?我想不通...非常感谢任何想法

最佳答案

我觉得很尴尬。经过几天的思考并回到这个问题上,当我最终决定发布一个问题时,一个想法在我做完之后突然闪现......

问题出在 header Content-type 上。它必须设置为 JSON:

Content-type: application/json

关于go - AMP 表单始终显示提交错误,即使响应代码为 200,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52526339/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com