これが私の問題です。jQueryを使用してxmlhttpRequestのresponseTextに基づいてテキストフィールドのcssスタイルを変更しようとしています。会社名がすでに取得されている場合、phpファイルは「CompanyNameAlreadyTaken」をエコーします。comp_statボックスの背景を赤に変えたいです。会社名が一意の場合、phpファイルは「CompanyName Ok」をエコーし、comp_statボックスの背景を緑色に変えたいと思います。
これは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";
}
/*----------------*/
}
これで何時間も頭を悩ませてきました、それはおそらく簡単な修正です...どんな助けでも大歓迎です!