Показать сообщение отдельно
  #9 (permalink)  
Старый 16.12.2018, 17:34
Аспирант
Отправить личное сообщение для oslayer Посмотреть профиль Найти все сообщения от oslayer
 
Регистрация: 18.10.2012
Сообщений: 63

Всё равно проходит редирект
<main>
    <form id="chimp1" action="https://made-in-altai.us19.list-manage.com/subscribe/post?u=55cf009edf905bbae51535dda&amp;id=9458b84861" method="post" novalidate>
        <h2>Subscribe to our mailing list</h2>
        <div id="js-form-inputs">
            <div>
                <label for="mce-EMAIL">Email Address<sup>*</sup></label>
                <input type="email" name="EMAIL" id="mce-EMAIL" value="" placeholder="Email">
            </div>
            <div>
                <label for="mce-FNAME">First Name </label>
                <input type="text" name="FNAME" id="mce-FNAME" value="" placeholder="First name">
            </div>
            <div>
                <label for="mce-LNAME">Last Name </label>
                <input type="text" name="LNAME" id="mce-LNAME" value="" placeholder="Last name">
            </div>
        </div>

        <!-- honeypot -->
        <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" id="js-validate-robot" name="b_55cf009edf905bbae51535dda_9458b84861" tabindex="-1" value=""></div>

        <!-- submit -->
        <button type="submit" name="subscribe" id="mc-embedded-subscribe">Subscribe</button>

        <!-- response -->
        <p id="js-subscribe-response"></p>
    </form>
</main>






<script>/*
 * Mailchimp AJAX form submit VanillaJS
 * Vanilla JS
 * Author: Michiel Vandewalle
 * Github author: [url]https://github.com/michiel-vandewalle[/url]
 * Github project: [url]https://github.com/michiel-vandewalle/Mailchimp-AJAX-form-submit-vanillaJS[/url]
 */
$(document).ready(function() {

    $('#chimp1').submit(function (e) {

    e.preventDefault();


 
     // Check for spam

        if(document.getElementById('js-validate-robot').value !== '') { return false }

 

        // Get url for mailchimp

        var url = this.action.replace('/post?', '/post-json?');

        // Add form data to object

        var data = '';

        var inputs = this.querySelectorAll('#js-form-inputs input');

        for (var i = 0; i < inputs.length; i++) {

            data += '&' + inputs[i].name + '=' + encodeURIComponent(inputs[i].value);

        }

 

        // Create & add post script to the DOM

        var script = document.createElement('script');

        script.src = url + data;

        document.body.appendChild(script);

 

        // Callback function

        var callback = 'callback';

        window[callback] = function(data) {

 

            // Remove post script from the DOM

            delete window[callback];

            document.body.removeChild(script);

 

            // Display response message

           document.getElementById('js-subscribe-response').innerHTML = data.msg

        };

    };

});
</script>
Ответить с цитированием