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 37 38
|
var xmlhttp = getXMLHttpRequest();
if(xmlhttp == null){
window.alert("Navigateur ne supporte pas ajax");
return;
}
xmlhttp.open("GET", "ajax/user_exists.php?username=" + username.value, true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4){
var response = xmlhttp.responseText.parseJSON();
if(response.result == true){
window.alert("Nom d'utilisateur existe");
username.select();
return;
} else if(typeof(response.result) == "string"){
window.alert("Message d'erreur: "+response.result);
return;
}
}
};
xmlhttp.send(null);
var captchaCode = document.getElementById("captcha_code");
xmlhttp.open("GET", "ajax/check_captcha.php?captcha_code=" + captchaCode.value, true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4){
var response = xmlhttp.responseText.parseJSON();
if(response.result == false){
window.alert("Code captcha incorrect");
captchaCode.select();
return;
}
}
};
xmlhttp.send(null); |
Partager