I encounter this problem when I use AJAX in javascript.
function showUsernameStatus() {
if (usernameRequest.readyState == 4) {
if (usernameRequest.status == 200) {
console.log(typeof(usernameRequest.responseText));
console.log(usernameRequest.responseText);
if (usernameRequest.responseText == 'ok') {
console.log(111);
document.getElementById('username').className = 'approved';
usernameValid = true;
}else{
console.log(222);
document.getElementById('username').className = 'denied';
document.getElementById('username').focus();
document.getElementById('username').select();
usernameValid = false;
}
}
checkFormStatus();
}
}
The value of usernameRequest.responseText is ok and the type is string, however it dose not equal to the string 'ok'. please tell me why, thank you very much!!!