0

I am using malsups form.js to run a login script combined with the zoo visitor add-on. When the login form has been successful the user is successfully logged in with out any need of a page refresh, although when I want to display the username the page needs to be refreshed for those details to appear on screen. Below is my code, any suggestions ?

--

                        <div class="username_wrap">
                            <p>Welcome 
                                <span>
                                    {exp:zoo_visitor:details}
                                            {visitor:member_firstname}
                                    {/exp:zoo_visitor:details}
                                </span>
                            </p>
                        </div>

$("#userLoginForm").ajaxForm({

dataType: "json", success: function (event) {

                if (event.success) {
                    member_favourites = "5";
                    //do something
                } 
            }
        })

2 Answers 2

3

Create a hidden template that is just the logged in username only. Then load it in via jquery ajax .load(); Once login is complete as well.

               if (event.success) {
                    member_favourites = "5";
                    //do something
                    $("div#username").load("_username.html");
                } 
2
  • Champion! appreciate that
    – Sam Crowe
    Commented Mar 29, 2014 at 20:04
  • Glad to help holler if you need anything else @buildmidwestern Commented Mar 29, 2014 at 20:13
0

With this code it's working fine:

            $('#form').ajaxForm({
                dataType: 'json',
                success: function(data) {
                    if (data.success) {
                        $("#jqxwindow ").jqxWindow({ height:150,
                                                    width: 250,
                                                    theme: 'bootstrap',
                                                    content: 'Você é registrado',
                                                    resizable: false
                                                                        });
                        $('#jqxwindow').on('close', function (event) {
                            alert("You closed a window");
                           );


                    } else {
                        alert('Failed with the following errors: '+data.errors.login);
                    }
                }
            });

Your code is in the header or footer?? If footer, you have to wrap it with document ready:

$( document ).ready(function() {

the code here

});

In the example code, the box message are from the Jqx framework , but with a simple js alert box it will work too.

1
  • Hi Stephane, yes that example does work in regards to showing if an ajaxForm is working, although i need to know how to change the zoo visitor details after a user logs in asynchronously. Hope that makes sense. User still needs to refresh the page to see the visitor:details
    – Sam Crowe
    Commented Mar 29, 2014 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.