'Contact form 7 send data and redirect to other domain page in wordpress

I have multiple Contact form 7 on wordpress and I want one form to redirect with send post data to other domain page. I have added below code in functions.php for redirect my specific contact form,data was send successfully but page was not redirecting.

add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');
function wpcf7_custom_form_action_url($url)
{
global $post;
$id_to_change = 5240;
if($wpcf7_contact_form->ID === $id_to_change)
    return 'http://34.209.247.91:8069/page/register';
else
    return $url;
}


Solution 1:[1]

The following is an example of script that redirects you to another URL when the wpcf7mailsent event occurs.

<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = 'http://example.com/';
}, false );
</script>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chinou