Google AMP:表单提交失败::意外令牌<在JSON中的位置1 [英] Google AMP: Form submission failed:: Unexpected token < in JSON at position 1

查看:144
本文介绍了Google AMP:表单提交失败::意外令牌<在JSON中的位置1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用amp-form组件添加了一个表单,它可以完美验证.

I have added a form using the amp-form component and it validates perfectly.

但是,当我提交表单时出现错误:

However, when I submit the form I get the error:

log.js:399未捕获的SyntaxError:表单提交失败::意外令牌<在JSON中的位置1

有什么主意吗?

推荐答案

这不是AMP问题,它是消息状态中的语法错误.正在向服务器发送/从服务器返回JSON的样子.您确定要发送/接收您认为要发送/接收的内容吗?

This isn't an AMP problem it's a syntax error as the message states. What does the JSON look like that is being sent/returned to/from the server. Are you sure you're sending/receiving what you think you're sending/receiving?

错误消息告诉我,您甚至没有得到JSON,而是得到了HTML.通过AJAX提交表单时,我遇到了此错误,并且由于服务器正在返回HTML消息供浏览器显示,所以它出错了,但是代码期望返回JSON.

The error message to me means you're not even getting JSON, but HTML. I've experienced this error upon form submission via AJAX and it was erroring out because the server was returning an HTML message for the browser to display, but the code was expecting JSON to be returned.

在调试器控制台中查看服务器从网络"选项卡下返回的内容.在网络"标签下的列表中找到网络呼叫后,您将选择响应"标签(网络的子标签).我的猜测是您的响应"选项卡将只显示HTML,而位置1处的字符是.......<".

Look in the debugger console at what is being returned under the Network tab from the server. After you locate the network call in list under the network tab, you'll select the response tab (sub tab of network). My guess is your response tab will show you nothing but HTML, with the character in position 1 being ....... "<".

该HTML可能还会提示您为什么也会失败.

That HTML will probably clue you into why it's failing as well.

祝您好运,希望对您有帮助!

Good luck, hope this helps!

这篇关于Google AMP:表单提交失败::意外令牌&lt;在JSON中的位置1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆