Ok here is my problem. I am trying to change the css style of a text field based on the responseText of an xmlhttpRequest using jQuery. If the company name is already taken the php file will echo "Company Name Already Taken." and I want the comp_stat box background to turn red. If the company name is unique the php file will echo "Company Name Ok" and I want the comp_stat box background to turn green.
这是“javascript”,所选案文是没有发挥作用的部分。
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
document.getElementById("comp_stat").value = xmlhttp.responseText;
/*Not working part*/
if(xmlhttp.responseText == Company Name Already Taken. ){
document.getElementById("comp_stat").style.backgroundColor = "red";
}
if(xmlhttp.responseText == Company Name OK! ){
document.getElementById("comp_stat").style.backgroundColor = "green";
}
/*----------------*/
}
我的头盔已满数小时,这或许是一个简单的固定点。 任何帮助都将受到高度赞赏。