• Resolved BrianRayA

    (@brianraya)


    Dear sir/madam,

    I am running MC4W on its own, so no form plugin or whatsoever. The main language of the site is english. Its translated with WPML to Dutch and German.

    When a user subscribes himself to the english (main) version, the spinner will load, the user will see a message that he succeeded the subscript and will get a redirection to a thank-you site with a discount coupon, etc. This doesn’t happen on the Dutch and the German version. The spinner keeps on loading. We get their information, that is not the issue but they dont see the succes and the thank you messages including the discount coupon. This is a serious problem and occured since the new WordPress update.

    When pressing submit on the Dutch/German version. Console will print out this.

    XMLHttpRequest cannot load https://bertplantagie.com/wp-admin/admin-ajax.php?mc4wp_action=subscribe. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://bertplantagie.nl' is therefore not allowed access.

    I have received support earlier but this didn’t solve anything and I didnt received any reply’s on my questions.

    Thanks in advance

    https://bertplantagie.com/newsletter/ (Main EN version)
    https://bertplantagie.nl/nieuwsbrief/ (NL version)
    https://bertplantagie.de/newsletter/ (DE version)

    https://www.ads-software.com/plugins/mailchimp-for-wp/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Brian,

    It seems that your various site languages are all hosted on a different domain (.com, .nl and .de). Since the form is submitted using AJAX, a client-side JavaScript request is sent from your .nl domain to your .com domain (which hosts the WP Admin panel).

    When the request is received by the .com domain, it is denied access because by default, a server will only allow AJAX requests from its own domain.

    To fix this, you will need to add your other domains to a list of trusted domains using the “Access-Control-Allow-Origin” header. You can do this by adding the following snippet to the top of your wp-config.php file.

    header('Access-Control-Allow-Origin: https://bertplantagie.com');
    header('Access-Control-Allow-Origin: https://bertplantagie.nl');
    header('Access-Control-Allow-Origin: https://bertplantagie.de');

    Hope that helps. If not, let me know!

    Thread Starter BrianRayA

    (@brianraya)

    Hi Danny,

    Thanks for your response but could you explain me the why it gives this error right now?

    XMLHttpRequest cannot load https://bertplantagie.com/wp-admin/admin-ajax.php?mc4wp_action=subscribe. The 'Access-Control-Allow-Origin' header has a value 'https://bertplantagie.de' that is not equal to the supplied origin. Origin 'https://bertplantagie.nl' is therefore not allowed access.

    Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Brian,

    Scratch that – I was wrong in my previous answer. You should actually be using the following code.

    $trusted_domains = array(
    	'https://bertplantagie.com',
    	'https://bertplantagie.nl',
    	'https://bertplantagie.de'
    );
    
    if( ! empty( $_SERVER['HTTP_ORIGIN'] ) && in_array( $_SERVER['HTTP_ORIGIN'], $trusted_domains ) ) {
    	header( sprintf( "Access-Control-Allow-Origin: %s", $_SERVER['HTTP_ORIGIN'] ) );
    }

    What this does is it will check if the request is coming from one of your trusted domains. If so, it will tell the server to allow access.

    Hope that helps. If not, let me know!

    Thread Starter BrianRayA

    (@brianraya)

    Hi Danny!

    This solution really worksout!

    Many kudos for you! i’ve been searching for a solution forever.

    Thanks!

    Plugin Author Danny van Kooten

    (@dvankooten)

    Awesome Brian, I’m glad that works. Thanks for letting me know!

    PS. Should you have a quick minute to spare, a plugin review here on www.ads-software.com would make us quite happy. ??

    Thread Starter BrianRayA

    (@brianraya)

    Sure! Will do!

    Thanks again for the help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Translated form not giving succes message, stuck on loading’ is closed to new replies.