-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error messages in AMP pages when using a Form #1356
Comments
I'm seeing the same.
The response headers from the request are:
From looking at the MDN docs on If you remove that header, does it work? |
I can see that the plugin isn't properly handling form requests form the AMP cache. The |
Do you mean our website header, I mean the one used by Wordpress? So refresh and test now please. |
I've also made a tiny change on the wepage. I made it so you can make sure you're using the new version of the website with no header content. Unfortunately my test indicated the same errors. Jose |
Website header? No. I'm talking about this HTTP response header:
Where is that coming from? You have some theme or plugin code that is sending that. |
The full response headers coming from your ajax handler at https://dragutierrez.com/wp-admin/admin-ajax.php are: HTTP/1.1 200 OK
Date: Thu, 30 Aug 2018 00:16:29 GMT
Content-Type: application/json
Content-Length: 104
Connection: keep-alive
Set-Cookie: __cfduid=[redacted]; expires=Fri, 30-Aug-19 00:16:27 GMT; path=/; domain=.dragutierrez.com; HttpOnly
X-Robots-Tag: noindex
X-Content-Type-Options: nosniff
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
X-Frame-Options: SAMEORIGIN
Referrer-Policy: strict-origin-when-cross-origin
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *.ampproject.org
AMP-Access-Control-Allow-Source-Origin: https://dragutierrez.com
Vary: Accept-Encoding
Content-Encoding: gzip
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: [redacted] The |
@dominointernet I've created a fix for the issue that I've been able to reproduce using Jetpack Contact Form module. See #1382 (comment) for a new plugin build of 1.0-beta2. However, I can see that Contact Form 7 is not going to work currently with AMP because when a submission is received it does not do a redirect to the success page. All AMP form submissions are done via XHR/Ajax, and AMP requires an It's on our list to look at improving Contact Form 7 support for AMP. But in the mean time, it's not going to work. See also #1378. |
I see. |
We could also use DIVI's Theme Form Module (our site uses DIVI Theme already). Would that be better you think? |
That looks like it could solve the problem. I see it does a |
Unfortunately the plugin CF7 Redirect doesn't seem to work: the AMP page doesn't redirect me to the "thanks" page. Thanks page is: https://dragutierrez.com/gracias/ I keep on getting the same errors:
|
@dominointernet Please try with the plugin build ZIP I linked to at #1382 (comment). That has the fix for the CORS issue. |
I did get an improvement now: we get to the Thanks Page if we fill up all the mandatory fields.
Thanks a lot for your help! Jose |
You can bypass that issue that by ensuring that you use HTML5 form validation attributes on your form fields. So required inputs should have the |
You also need to make sure that the add_filter( 'wpcf7_form_novalidate', '__return_false' ); |
And a quick way to ensure that add_filter( 'wpcf7_form_elements', function( $elements ) {
return str_replace( 'aria-required="true"', 'required', $elements );
} ); |
Hi, |
@Prashanthspokesly Here is an extension to the AMP plugin which adds basic support for Contact Form 7: https://gist.github.com/westonruter/3501016b0d44af45d878067b1856e023 |
@westonruter the plugin does not work for me. I get following error:
|
@rajmdtu Try navigating to https://minklashbarny.com/passages/contact/?_wp_amp_action_xhr_converted=1&__amp_source_origin=https%3A%2F%2Fminklashbarny.com Notice the error message:
You need to adjust the ModSecurity rules to allow the |
Thank you for the quick response. |
Hello,
The Form at the bottom of our web pages briefly displays a “Form sent successfully” message and then redirects users to a “Thanks” page. The form uses ContactForm7.
Unfortunately, the AMP version of these same pages doesn’t do either one thing or the other: no succesful message and no redirection.
We noticed we don't get in the AMP pages the usual message on mandatory fields that are left empty by the user.
And we found 2 error messages in our code (when we check the page in Developer mode in Chrome). See below.
The problem is that users don’t have any verification that their form was sent to us so they insist clicking on the Submission button several times, creating fustration on them and filling up our email foder with dozens of copies of the same forms.
Original URL (CF7 works great here): https://dragutierrez.com/tratamientos/medicina-estetica/dermapen/
AMP URL (where CF7 doesn't work): https://dragutierrez-com.cdn.ampproject.org/c/s/dragutierrez.com/tratamientos/medicina-estetica/dermapen/?amp
These are the error messages we get:
Powered by AMP zap HTML – Version 1534444305877 https://dragutierrez-com.cdn.ampproject.org/c/s/dragutierrez.com/tratamientos/cirugia-plastica/ginecomastia/precio-de-la-ginecomastia/?amp
dragutierrez-com.cdn.ampproject.org/:1 Failed to load https://dragutierrez.com/wp-admin/admin-ajax.php?action=ampcf7_submit_form&_wp_amp_action_xhr_converted=1&__amp_source_origin=https%3A%2F%2Fdragutierrez.com: The 'Access-Control-Allow-Origin' header contains the invalid value '*.ampproject.org'. Origin 'https://dragutierrez-com.cdn.ampproject.org' is therefore not allowed access. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
log.js:187 Form submission failed: Error: XHR Failed fetching (https://dragutierrez.com/...): Failed to fetch ... log.js:187
That js.187 line says:
fn.apply(this.win.console, messages);
I'm not sure but I wonder if there could be an issue with the way your plugin deals with Ajax.
Any help appreciated.
NOTE: we've also tested a simpler scenario using WP default theme (twenty seventeen and deactivating CF7 Redirection plugin.
Thanks in advance,
Jose Delgado
The text was updated successfully, but these errors were encountered: