Support » Plugin: AMP » WPForms – Failed to parse response JSON

  • Resolved Jan Pencik

    (@janpencik)


    Dear support,

    I am having problems implementing WPForms with the newest version of AMP plugin. In the version 2.0.0 and newer, submit button gets stuck on Sending… and I receive this error in the console:

    [amp-form] Failed to parse response JSON: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

    Email is delivered but it’s not very user friendly to not display any feedback of message being sent to the user so I am trying to fix it.

    With the 1.5.5 version, success/error notification is normally shown under the form after submitting the form.

    Do you have any idea where this may come from? I tried to test it both on localhost and testing environment and got the same error.

    Thanks for any help!

    • This topic was modified 1 year, 5 months ago by Jan Pencik. Reason: adding URL
    • This topic was modified 1 year, 5 months ago by Jan Pencik.
    • This topic was modified 1 year, 5 months ago by Jan Pencik. Reason: Editing of the title

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter Jan Pencik

    (@janpencik)

    Oh, forgot to include URL. Edited previous post. The form is on the bottom of the page.

    • This reply was modified 1 year, 5 months ago by Jan Pencik.

    @janpencik thanks for reaching out! When I test WP Forms on an AMP page on my test site, I’m not getting the error. Some items to help troubleshoot:

    1) Could you check for any validation errors on the page under AMP > Validated URLs?

    2) Are you able to temporarily switch to Transitional Mode and attempt the using the form on the non-AMP version of the page to ensure it works there?

    Thread Starter Jan Pencik

    (@janpencik)

    Hi Renee, thanks for your reply. No validation errors on those pages. Setting website to Transitional Mode solves the issue, but is not a solution for me. I need to run all pages in standard AMP mode.

    @janpencik thanks for the update!

    Setting website to Transitional Mode solves the issue, but is not a solution for me.

    Yes, this was a troubleshooting step. To confirm: the form works on both the AMP version and non-AMP version in this mode (or just the non-AMP version)?

    Do you have any security measures applied on the site either by a plugin or your host (such as ModSecurity)? Something may be interfering with the form request/ response on the site.

    Thread Starter Jan Pencik

    (@janpencik)

    Well, I managed to fix the issue. You won’t believe me what was causing the problem šŸ˜€

    So first of all I found out that the theme is the problem. I created fresh WP installation and added both plugins there to test it out. Everything was working with default Twenty Twenty-One theme. My custom theme wasn’t.

    I tried to copy things from default theme to my theme to figure out if I am not missing any needed feature. I copied every extra feature from functions, header and footer but it was still not working. So I tried opposite approach… I started to delete everything from Twenty Twenty-One theme until I had super bare bones skeleton of basic HTML tags, blank functions.php and the form was still working on default theme. When I copied the same skeleton to my custom theme, it wasn`t working.

    And now comes the workaround. I found out that the form is working only if I rename my theme to the same name as one of the default themes has. This includes theme folder + Theme Name and Text Domain in style.css – then it’s working without any issues. I tested both on localhost and testing server for Twenty Nineteen and Twenty Twenty-One and both names were working. On the other side I tried different other names of the theme (one word, two words) to mimic the name of default WP themes and wasn’t successful.

    Thanks, Renee, for your help – I think I am fine with this workaround for now šŸ™‚

    @janpencik nice troubleshooting and that’s super interesting!

    Do you mind sharing the name of your theme (you can provide it through this form if preferred)? Did it have any special characters? It would be interesting to see if we can reproduce this on our side.

    Maybe this helps … I observed the same issue and posted a topic one week ago on the wpforms plugin page https://wordpress.org/support/topic/amp-issue-16/

    In my case the theme is OceanWP.

    @max2k thanks so much for the tip!

    I am having this same issue. I am using a Genesis child theme.

    I tried activating the bare Genesis Sample theme… got the same error. Also tried activating the Genesis Parent theme… got the same error.

    I reached out to Studiopress and they gave me a fix. I’m adding the solution here in case someone else gets the same issue.

    You just have to add this to functions.php:

    add_filter( 'wpforms_is_amp', '__return_true' );

    Studiopress said that the case could be that WP Forms isn’t detecting that Genesis themes are AMP compatible. Adding that filter to functions.php fixes it.

    • This reply was modified 1 year, 5 months ago by Hazel Z..
    • This reply was modified 1 year, 5 months ago by Hazel Z..

    @cadencehart thanks for sharing your experience and this solution!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘WPForms – Failed to parse response JSON’ is closed to new replies.