警告值显示为初始值,但if(checkoption == 'Initial')
的条件返回始终为false .........
实际代码是这个..
function changeItem(id,item,option) {
var xhttp;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if(this.responseText=="Initial"){
$("#Initial").load("Item-<%=cha_id%>.html #Initial", function()
{
document.getElementById("Initial").style.display = 'block';
document.getElementById("Final").style.display = 'none';
});
}
if(this.responseText=="Final"){
$("#Final").load("Item-<%=cha_id%>.html #Final", function()
{
document.getElementById("Initial").style.display = 'none';
document.getElementById("Final").style.display = 'block';
});
}
}
};
xhttp.open("GET", "<%=landingpage_basepath %>/ChangeItemValue111?info="+id+"&item="+item+"&option="+option, true);
xhttp.send();
}
}
答案 0 :(得分:0)
这是更正后的代码。
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var checkoption=this.responseText;
alert(checkoption);
if(checkoption == 'Initial') { alert(this.responseText); }
else if(checkoption=="Final"){ alert(this.responseText); }
else { alert("Hello"); }
}
};
xhttp.open("GET", "<%=landingpage_basepath %>/ChangeItemValue111?info="+id+"&item="+item+"&option="+option, true);
xhttp.send();