hi,
i am doing my first application using Ajax. I am strucked with one problem. If any one helps me in this, i am so thankful to them.
I am able to get xml
doc using "xmlHttp.responseText". But when i try to execute this
var xmlDoc=xmlHttp.responseXML.documentElement;
Above statement returns null.
Do i need to install any plug-ins or else(But i heard that for Ajax no additional software is needed).
Here is my full code :
function getDetails(str)
{
xmlHttp = GetXmlHttpObject();
if(xmlHttp == null)
{
alert("Your browser does not support AJAX");
return;
}
var url = "Ajax_DOM.xml";
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
try
{
if (xmlHttp.readyState==4)
{
//alert(xmlHttp.responseText)
var xmlDoc=xmlHttp.responseXML.documentElement;
var objNodeList = xmlDoc.getElementsByTagName("wkt");
for (var i=0;i<objNodeList.length;i++)
{
var no = new Option();
no.text = objNodeList[i].childNodes[0].nodeValue;
no.value = objNodeList[i].attributes[0].value;
document.company.comptype[i+1]= no
}
}
}
catch(e)
{
//alert("Plese enter correct voicefilename : " + e);
}
}
function GetXmlHttpObject()
{
var 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;
}
Please help me in this.
Regards,
Praveen