• Resolved Ced

    (@cedriccharles)


    Hi !

    I’m using your plugin to get subscribers on my website (I’m using the widget). My website use AJAX for the page navigation. If I reload the page with the widget, everything goes fine ! But if I start navigate from an other page and load the page with the widget throught AJAX, the form doesn’t work (of course, the Mailjet’s JS are not in the page -> not triggered).

    Could you please help me on this ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mailjet

    (@mailjet)

    Hello Cédric,

    Have you tried to load the Mailjet JS also on the other pages (not only on the page with widget) and see what happens?

    Best regards,
    Mailjet Team

    Thread Starter Ced

    (@cedriccharles)

    Hello !

    I have loaded the JS on all pages but as the “submit” button is not in the page on the first load, it doesn’t work after the AJAX load. I need to trigger the script on page change. Do you have something for that ?

    Thank you in advance 🙂

    Plugin Author Mailjet

    (@mailjet)

    Hello again,

    We don’t have the same setup as you so we are not able to test properly, but would you try a quick fix?

    Try to replace the contents of this file in the plugin: assets/js/ajax.js
    with the following code: https://pastebin.com/Vu5ujTHy

    Please let me know if it works.

    Best regards,
    Mailjet Team

    Thread Starter Ced

    (@cedriccharles)

    Hi @mailjet 🙂 !

    Thank you for your answer ! It doesn’t work, because you do the click on an element that is still not in the page. But with the following code, it works because we do the click event on the “body”, which is all the time present, in every pages of course 😉 :

    jQuery(document).ready(function ($)
    {
        $('body').on('submit', '.subscribe-form', function (e)
        {
            e.preventDefault();
            var $el = $(this);
            var loading = '<p><img src="' + WPMailjet.loadingImg + '" alt="Please wait..."></p>';// Loading state
            var $res = $el.parent().find(".response").html(loading);// Clear previous messages
            $.post(WPMailjet.ajaxurl, $el.serialize(), function (data)
            {
                $res.html(data);
            });
        });
    
        $('body').on('click', '.widget-control-close', function (e)
        {
            var $res = $(this).closest('form').find(".mailjet_subscribe_response");
            if (jQuery.type($res.html()) !== undefined)
            {
                $res.hide();
            }
        });
    });

    Could you do something about it ?

    Plugin Author Mailjet

    (@mailjet)

    Should be fixed in v. 4.3 of the plugin. Please let us know if the problem persists.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Subscribe Widget with AJAX website’ is closed to new replies.