ajaxresponseTextの状況が発生しています。URLからの応答テキストはうまく機能しています。しかし、ajaxコード内の何かがうまくいかない。応答テキストを認識せず、ターゲットIDにクラスを追加します。コードは次のとおりです。
<script type="text/javascript">
function updateField(nameValue){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!");
return false;
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
if (xmlHttp.status==200){
//this will be called after update
var responseText = xmlHttp.responseText;
}
}
}
//this will send the data to server to be updated
xmlHttp.open("GET", 'inc/room_rate_updatez.php?'+ nameValue, true);
xmlHttp.send(null);
}
function doSomethingAfterUpdate(retValFromPHP){
//retValFromPHP can be any thing you want!
if (reponseText == "Failed"){
document.getElementById("result").innerHTML=xmlhttp.responseText.className = "error";
}else{
document.getElementById("result").innerHTML=xmlhttp.responseText.className = "success";
}
}
</script>
<div id="result"></div><input type="text" name="rate|498|6500-5200-4600-5600-4100|0" id="498" value="6500" size="10" onchange="updateField(this.name + '=' + this.value);"/>
room_rate_updatez.phpからの応答は、「成功」と「失敗」です。私はそれを機能させるために何度も試みましたが、運がありません。提案してください。