• Using 5.16 version. The redirection has stopped working suddenly.

    The following code is added for redirection but not working.

    <script>
    document.addEventListener( ‘wpcf7mailsent’, function( event ) {
    var a = document.getElementById(“job-opening-form-name”).value;
    var url = ‘https://www.peppersquare.com/careers/thank-you/?’+a;
    if ( ‘1281’ === event.detail.contactFormId ) {
    location = url;
    }
    }, false);
    </script>

    Your help is highly appreciated.

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

Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    What other plugins and theme do you use on the site?

    Thread Starter nileshpsq

    (@nileshpsq)

    I’m using Divi theme plus other plugins. But this was working earlier and suddenly it has stopped.

    The code you’ve specified appears on the page TWICE.

    BTW, my Adblocker blocks some CDN resources. Could that be involved?

    Thread Starter nileshpsq

    (@nileshpsq)

    I was testing, therefore, the code is twice, as in one blog it said to put in header but that’s not working as well.I’ll remove that. Thje emails are sent while hitting submit but the page doesn’t redirect to the thank you page. So users hit submit button multiple times.

    Not using in adblocker. A lot of my customers have also complained about this.

    When I type var a = document.getElementById("job-opening-form-name"); into my browser console, I get the response undefined.

    However, when I remove the var, I get the correct response (field HTML).

    Weird, but maybe just remove the var from your code.

    Thread Starter nileshpsq

    (@nileshpsq)

    job-opening-form-name is the field name of which is the Name field. This is passed in the url.
    https://www.peppersquare.com/careers/thank-you/?’+a

    So if you type https://www.peppersquare.com/careers/thank-you/?Gal you should see the thank you page with your name.

    Not if your Javascript never gets there. Read my message again and try it.

    Thread Starter nileshpsq

    (@nileshpsq)

    You mean just put like this?

    a = document.getElementById(“job-opening-form-name”).value;

    Yep.

    Thread Starter nileshpsq

    (@nileshpsq)

    document.addEventListener( ‘wpcf7mailsent’, function( event ) {
    a = document.getElementById(“job-opening-form-name”).value;
    var url = ‘https://www.peppersquare.com/careers/thank-you/?’+a;
    if ( ‘1281’ === event.detail.contactFormId ) {
    location = url;
    }
    }, false);

    I used the above and still the same issue. The loading icon keeps running and the page does not go to thank you page.

    What I would do is add console.log() statements to find out how the script flows and what value things have.

    BTW, when you share code, use 3 backticks on a separate line before and after the code.

    Try this:

    
    document.addEventListener( 'wpcf7mailsent', function( event ) {
    	var a = document.getElementById('job-opening-form-name').value;
    	console.log('a = '+a);
    	var url = 'https://www.peppersquare.com/careers/thank-you/?'+a;
    	console.log('url = '+url);
    	console.log('contactFormId = '+event.detail.contactFormId);
    	if ( '1281' === event.detail.contactFormId ) {
    		location = url;
    	}
    }, false);
    
    Thread Starter nileshpsq

    (@nileshpsq)

    Code added.

    Thread Starter nileshpsq

    (@nileshpsq)

    @galbaras Any luck with the code. I appreciate you helping me with this.

    I’m not sure what you mean.

    Test the code and look in your browser’s console to see what’s printed. You have to open the code inspector for this.

    Thread Starter nileshpsq

    (@nileshpsq)

    Unfortunately, it does not print anything in the console.

    https://www.peppersquare.com/careers/job-openings/senior-storyteller-and-creative-writer/

    This is the URL to test. Maybe you can do form submit and check?

    Thanks for the help.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Redirection not working’ is closed to new replies.