Strange Ajax/jQuery/PHP login issue -


i have dynamic login header. 2 links, login / register , profile / logout.

i have php class function being used check if logged in , displaying relevant links, worked fine.

i moved ajax login didn't want page refresh , login box drops down , rolls up. again, works fine.

i've noticed slight issue, slight mean irritating :)

once logged in, every single page refresh on new page shows flicker 'profile' becomes 'login' , flickers again. happens when page loading , doesn't last long it's not nice.

could me solve please? i'm pretty new ajax/jquery , spent ages wiht of guys in here getting ajax/jquery part functional in first place.

this script toggles login divs

<script>         window.onload = function(){             $(function() {                 var loggedin = <?php echo json_encode($general->loggedin()); ?>;                 $("#loggedin").toggle(loggedin);                 $("#loggedout").toggle(!loggedin);             });         }     </script> 

thanks

edit: ajax

function validlogin(){  $('#error').hide(); var username = $('#username').val(); var password = $('#password').val();  if(username == ""){     $('input#username').focus();     return false; }  if(password == ""){     $('input#password').focus();     return false; }  var params = {username: username, password: password}; var url = "../loginprocessajax.php";  $("#statuslogin").show();  $.ajax({     type: 'post',     url: url,     data: params,     datatype: 'json',     beforesend: function() {       document.getelementbyid("statuslogin").innerhtml= '<img src="../images/loginloading.gif" /> checking...' ;     },      success: function(data) {          $("#statuslogin").hide();          if(data.success == true){              $('#loggedin').show();             $('#logincontent').slidetoggle();             $('#loggedout').hide();          }else{            // alert("data.message... " + data.message);//undefined             $("#error").show().html(data.message);         }      },     error: function( error ) {         console.log(error);     } });  } 

// css-stylesheet  #loggedin, #loggedout {display: none}  <script>         $(document).ready(function() {             var loggedin = <?php echo json_encode($general->loggedin()); ?>;                  if (loggedin == true) { // can guess here...                 $("#loggedin").show();             }             else {                 $("#loggedout").show();             }         }); </script> 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -