• Resolved crosp

    (@crosp)


    Hi, thanks for such a great plugin. It works fine.
    But I have a few questions about the plugin.

    I am using PHP form, it works fine, but I need to change the behavior a little bit .
    Please note, all these questions refer to the Frontend (JS) part.
    1. Is it possible to get rid of the error message (invalid email…) or it would be much better if I could provide my own handler.
    2. How to listen for submit events, I need to get my function called when form is submitted, but I don’t want to alter the default behavior (AJAX call ..). I need just be notified when response comes.
    3. Also this question is related with the previous one, I need to get rid/alter the default message that is placed instead of a form after subscription.

    I would be grateful for any help.

    Thanks.

    • This topic was modified 9 years ago by crosp.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter crosp

    (@crosp)

    Here is my quick & dirty solution that doesn’t require modification of source files.

      var SubscriptionHandler = (function ($) {
            var handleSubscribeRequest = function (xhr, options) {
                var originalSuccessCallback = options.success;
                options.success = function (data, textStatus, jqXhr) {
                    alert("SUCCESS !!");
                    //originalSuccessCallback.apply(this, arguments)
                }
            };
            var interceptAjaxRequest = function () {
                $.ajaxSetup({
                    beforeSend: function (xhr, options) {
                        if (options.data.startsWith("action=wysija_ajax")) {
                            handleSubscribeRequest(xhr, options);
                        }
                    }
                });
            };
            var init = function () {
                interceptAjaxRequest();
            };
            return {
                init: init
            }
        })($);

    In case you want to modify source code of the plugin. This is handled inside plugins/wysija-newsletters/js/front-subscribers.js

    Here is the part.

        $.ajax({
                    type: "post",
                    url: wysijaAJAX.ajaxurl,
                    data: wysijaAJAX,
                    success: function (response) {

    But be ready to modify obfuscated code)

    Hope this helps someone.

    • This reply was modified 9 years ago by crosp.
    Wysija

    (@wysija)

    Unfortunately, we don’t provide this kind of support here. Perhaps, it’ll be easier if you create your own custom subscription form: http://docs.mailpoet.com/article/67-plugin-form-integrate

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to get a function executed on the submit callback (Frontend)’ is closed to new replies.