Javascript error: Cannot read property 'indexOf' of undefined

I have a problem with ajax login in wordpress theme. I am using ssl and wp-admin works. Only problem is that ajax login shows me an error and endless loading begin, so users can't login as well.

Error:

Uncaught TypeError: Cannot read property 'indexOf' of undefined

Code:

    if (can_submit) {
        if ($this.hasClass('register-form') || $this.hasClass('ajax-return')) {
            $this.append('<i class="fa fa-spin fa-spinner" style="margin-left: 10px;"></i>');
            $.ajax({
                url: ajaxurl,
                method: 'POST',
                data: $this.parents('form').serialize(),
                dataType: 'JSON',
                success: function (response) {
                    $('.ajax-response').html(response.message);
                    if (response.url) {
                        window.location.href = response.url;
                    }
                    if (response.message.indexOf('alert-success') > -1 && $this.hasClass('register-form')) {
                        $form.after($form.find('.ajax-response').clone());
                        $this.parents('form').remove();
                    }
                },
                complete: function () {
                    $this.html($html);
                }
            });
        }
        else {
            $form.submit();
        }
    }
    else {
        var error_message = $('.submit-form').data('form-error');
        if (typeof error_message !== 'undefined') {
            $('.submit-form').after('<small class="submit-form-error error"><br />' + $('.submit-form').data('form-error') + '</small>');
        }
    }

Thanks for helping me.