1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| var xhrConnexion;
function getConnexion(login, pwd){
if(login != "" && pwd != ""){
if (window.XMLHttpRequest) {
xhrConnexion = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
try {
xhrConnexion = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xhrConnexion = new ActiveXObject("Microsoft.XMLHTTP");
}
}
xhrConnexion.onreadystatechange = handleHttpResponseConnexion;
var url = "connexion.php";
xhrConnexion.open("POST", url, true);
xhrConnexion.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhrConnexion.send("login="+login+"&pwd="+pwd);
}
}
function handleHttpResponseConnexion(){
var reponse = 0;
if(xhrConnexion.readyState == 4 && xhrConnexion.status == 200) {
reponse = parseInt(xhrConnexion.responseText);
if(reponse == 1){
window.location.href="/";
}
}
} |
Partager