0

I'm calling an ajax function for user login. After successful login, I want to refresh a div with content like (Ex. Welcome Mr. User, logout).

HTML:

<ul id="signup">
   <li>Login</li>
   <li>Signup</li>
</ul>

<ul id="loginbox">
     <li><label>Enter email address</label><br/><input type="text" class="bookinginput" id="uemail"></li>
     <li><label>Enter password</label><br/><input type="password" class="bookinginput" style="width: 151px;" id="upassword">
     <button class="styled-button-8" style="margin-top: -43px;margin-left: 10px;" onClick="ulogin()">Login</button>
     </li>
</ul>

Ajax:

function ulogin()
{
    var uemail = $('#uemail').val();
    var upassword = $('#upassword').val();
    $.ajax({
        type: "POST",
        url: "udoologin.php",
        data: {email:uemail, password:upassword}
    }).done(function( result ) {
        $("#loginbox").html(result);  
    });
}

After successful login, I'm able to change div#loginbox with successfull login message, but I want to replace another div#signup also with

<ul id="signup">
   <li>Welcome <?php echo $user?></li>
   <li>logout</li>
</ul>

How can I achieve this?

1 Answer 1

1

In PHP when u are printing the result,echo

<li>Welcome <?php echo $user?></li>
   <li>logout</li>

joined with a seperator like '|||' or something.

in jquery

done(function( result ) {
 var log=result.split('|||');
 $("#loginbox").html(log[0]);
 $('#signup').html(log[1]);

});

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.