Hi,
I am using a Ajax to call a PHP script in order to authenticate users on my website. Depending on the response returned I am displaying one of two divs (success or failure). If the login is successful I want to display the name of the authenticated user within the welcome message on the relevant div.
My thoughts were to set a PHP SESSION variable in my login.php script and then reload the success div before I display it.
Here is my code:
- $.ajax({
- type: "POST",
- dataType: "json",
- data: "username="+user+"&password="+pass,
- url: "login.php",
- success:function(result){
- $('#mask').show().fadeTo('', 0.7);
-
- if(result['response']==1){
- $('div#alert.success').reload();
- $('div#alert.success').fadeIn();
- }
-
- if(result['response']==0){
- $('div#alert.fail').fadeIn();
- }
-
- $('div#alert, div#mask').click(function(){
- $('div#alert, div#alert, div#mask').stop().fadeOut('fast');
- location.reload();
- });
- }
-
- });
-
- return false;
-
- });
As you can see on line 10 I am trying to reload the div then fade it in but it doesn't work.
What am I doing wrong? Is my general approach correct?
Thanks in advance,
Johnny.