Google AMP: Form submission failed:: Unexpected token < in JSON at position 1

只愿长相守 提交于 2019-12-13 07:30:12

问题


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 Uncaught SyntaxError: Form submission failed:: Unexpected token < in JSON at position 1

Any idea?


回答1:


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?

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.

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 ....... "<".

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

Good luck, hope this helps!



来源:https://stackoverflow.com/questions/40483911/google-amp-form-submission-failed-unexpected-token-in-json-at-position-1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!