If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Refresh a div content after login

I am currently working on Ajax-Jquery,
- When user signin using Lightbox , after signin verification it will lead to the previous page without any refresh.
- Now my problem is after successful signin , I want to refresh the content of div in header portion without refreshing the whole page.
- Like Welcome User , my Account etc...
- Now i am able to retain in the previous page(but the header portion is able to refresh).
- the reference link below http://stackoverflow.com/questions/2...ogged-div?rq=1
- My try is ,
Code:

You can simply build the markup in your Javascript using the data returned from your successful login. This would involve you returning the necessary data in JSON when a User logs in successfully, then using that to build an HTML string. Alternatively, you can use a templating system like Handlebars to build the HTML string.

Options 3: Use AJAX to load page fragments

Note: This will only work if you already have a non-AJAX implementation of the logged in header

Now that you are logged in, assuming all the correct cookies/session data is set so that next time you reload the page, the correct header will be in place, you can use AJAX to request the new Header Div:

Code:

$( "#header_div" ).load( "homepage.php #header_div" );

This would, as the code suggests, make an AJAX request to homepage.php, extract the contents of #header_div and replace the "#header_div" on your page with it.

Thanks for your reply ,
But i Want to update only when the user "Signin" or "Signout" .
I will have user info in the $_SESSION , by which i want to update the header as follows
If(isset($_SESSION['user']))
{
echo "welcome".$_SESSION[''user];
echo "Logout";
}
else
{
echo "Signin";
}

So , after signin i just want to refresh the header to update the "welcome" .

Thanks for your detailed response,
I have tried with your
Option 1(.replaceWith)
- It works fine in the same page (after signin) , But the after moving to next page header retain as non login user.
Option 3(.load)
- Its repeating the header portion two times, because i already included the header file in the beginning of every file.
$( "#header_div" ).load( "header.php");
- My header file code follows,

So I dont want to fetch new data from external file, Instead i just want to refresh the header content.
Now I just hard core the "Welcome note" in the signin verification file and filling that in the header portion.