Klevis Miho
Klevis Miho

Reputation: 859

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

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?

Upvotes: 0

Views: 2174

Answers (1)

SBDuvallian
SBDuvallian

Reputation: 171

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!

Upvotes: 2

Related Questions