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;
}

Are you sure, did you put an alert() in the function to see?

thanks for your reply,

yes, i put alert() function and it did not display. When i put alert() just before the no-working function, the alert displays. it's strange,...

OOps, i solved it now, the closing brackets were wrongly aranged... how silly!

Oh, you did fix it, OK cool.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.