Hello everyone,
The ajax+php part worked well independently. When I created a switch (because I want different information from database to be displayed in different tabs), it does not go into the xmlHttp.onreadystatechange=function(). I tried all possible variations, and looked online for hours.
Can anyone help please?
Thank you
var moduleidd;
var xmlHttp;
function loadModules(moduleid, birdid)
{
switch (moduleid)
{
case "contentA":
document.getElementById("contentA").innerHTML = "Hello";
case "contentB":
{
xmlHttp=GetXmlHttpObject();
var url= "contentB.php";
url=url+"?q="+birdid;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=function(){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("contentB").innerHTML = "test test test 123";
var a = xmlHttp.responseText;
document.getElementById("contentB").innerHTML = a;
}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
};
};
case "contentC":
case "contentD":
case "contentE":
}
}
function GetXmlHttpObject()
{
xmlHttp=null;
try{
//Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}