嗨,我是新来的,我喜欢这个网站
我正在学习 javascript,到目前为止我已经完成了很多教程,但我无法让 ajax 工作。
我在 W3school 看到了这个
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();
现在我将一行改为
xmlhttp.open("GET","ajax_info.php?day="+document.getElementById("day").value,true);
它应该基于一天而不是所有天来读取信息。
有时页面是空的,什么也没有发生,有时它可以工作并且一切都在那里。
要重现,您可以连续按 F5 3 次,它至少会失败一次。
请帮我保存我还有的最后一点头发!