Click here to Skip to main content
15,867,834 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Want to bind the options in select tag. from my code it is working well in Firefox but in ie option value not bind to select tag.

here is my Javascript function
JavaScript
<script>
var xmlHttp;
function getsubdvr(str)
{
	alert("function");
	debugger;
	document.getElementById('ajax_loading').style.display='inline-Block';
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null)
	{
		alert("Your Browser Does'nt support Ajax!");
		return;
	}		
	var url="getsubcat.php";
	url=url+"?q="+str;
	//alert(url);
	xmlHttp.onreadystatechange=valuchange1;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function valuchange1()
{
	if(xmlHttp.readyState==4)
	{
		alert(xmlHttp.responseText);
		
		//alert(xmlHttp.responseText);
		document.getElementById('subidlistdvr').innerHTML=xmlHttp.responseText;
		//alert(xmlHttp.responseText);
		document.getElementById('ajax_loading').style.display='none'; 
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch(e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHttp");
		}
		catch(e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHttp");
		}
	}
	return xmlHttp;
}
</script>

thanks in advance.

Edit - Formatting applied
Posted
Updated 18-Nov-15 19:15pm
v8
Comments
Krunal Rohit 19-Nov-15 0:57am    
Share the code of this method:
GetXmlHttpObject();

-KR
Dipali Nigade 19-Nov-15 1:06am    
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}
catch(e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHttp");
}
catch(e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHttp");
}
}
return xmlHttp;
}
Krunal Rohit 19-Nov-15 1:07am    
Try this-
var http;

if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
http = new XMLHttpRequest();
}
else {
// code for IE6, IE5
http = new ActiveXObject("Microsoft.XMLHTTP");
}


-KR

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900