i made a login system using php and ajax.
the login is perfectly fine but however when i logout (by making a post request to logout.php) the whole page automatically refreshes after the request and response is complete.
the function logged_false() is called and executed and then the refresh takes place.
NOTE :: check out the above at phoenix.exofire.net using "nitesh" as both the username and password
the login is perfectly fine but however when i logout (by making a post request to logout.php) the whole page automatically refreshes after the request and response is complete.
Code:
[php]
//logout.php
session_start();
unset($_SESSION['uid']);
unset($_SESSION['pwd']);
session_destroy();
?>[/php]
Code:
//ajax call
function logout()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var param="";
//url=url+"&sid="+Math.random();
//alert("THIS IS THE REQ param :\n"+param);
xmlHttp.onreadystatechange=function ()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
logged_false();
// document.getElementById("register").innerHTML+=xmlHttp.responseText ;
}
}
xmlHttp.open('POST',url,true);
//xmlhttp.setRequestHeader("POST /"+url+"HTTP/1.1");
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-Length" , param.length);
xmlHttp.setRequestHeader("connection", "close");
//xmlHttp.setRequestHeader("\r\n\r\n");
xmlHttp.send(param);
}
NOTE :: check out the above at phoenix.exofire.net using "nitesh" as both the username and password