Hey there, I'm a newbie and absolutely loving this site!
Currently diving into the world of JavaScript and have been through numerous tutorials. However, I seem to be struggling with getting Ajax to work.
Recently stumbled upon this code snippet on 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();
Decided to tweak it by altering one line to:
xmlhttp.open("GET","ajax_info.php?day="+document.getElementById("day").value,true);
This change aims at fetching information specific to a certain day instead of all days.
Encountering a peculiar scenario where sometimes the page goes blank, glitches out, but then magically works fine on other occasions.
To replicate the issue, simply hit F5 three times consecutively - chances are, it will fail atleast once.
In desperate need of some guidance here before I lose the few hair strands left on my head! Please assist!