Aashish r's Profile

About

 
Points: 0

Contact

 

Aashish r
January 25, 2016 · Public

The ajax code doesnt work pls help
tuna.js:

var xmlHttp= createXmlHttpRequestObject()
//objetct crerationn
function createXmlHttpRequestObject()
{
var xmlHttp;
if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
else
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlHttp;
}

function process()
{
if(xmlHttp)
{
try{
xmlHttp.open("GET","tuna.xml",true);
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.send(null);
//alert("data sent");
}
}
catch(e)
{
alert(e.toString());
}
}

//state changes

function handleStateChange()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
try{
handleResponse();
}
catch(e)
{
alert(e.toString());
}
}
}
else
{
alert(xmlHttp.statusText);
}
}

//handling xml response

function handleResponse()
{
//alert("finishig up ");

var xmlresponse =xmlHttp.responseXML;
root=xmlresponse.documentElement;
names=root.getElementsByTagName("name");
ssn=root.getElementsByTagName("ssn");
theD=document.getElementById("theD");
var stuff="";
for(var i=0;i<names.length;i++)
{
stuff=names.item(i).firstChild.data + "-"+ssn.item(i).firstChild.data;

}
theD.innerHTML+=stuff;
}


Aashish r
January 25, 2016 · Public

The ajax code doesnt work pls help
tuna.js:

var xmlHttp= createXmlHttpRequestObject()
//objetct crerationn
function createXmlHttpRequestObject()
{
var xmlHttp;
if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
else
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlHttp;
}

function process()
{
if(xmlHttp)
{
try{
xmlHttp.open("GET","tuna.xml",true);
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.send(null);
//alert("data sent");
}
}
catch(e)
{
alert(e.toString());
}
}

//state changes

function handleStateChange()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
try{
handleResponse();
}
catch(e)
{
alert(e.toString());
}
}
}
else
{
alert(xmlHttp.statusText);
}
}

//handling xml response

function handleResponse()
{
//alert("finishig up ");

var xmlresponse =xmlHttp.responseXML;
root=xmlresponse.documentElement;
names=root.getElementsByTagName("name");
ssn=root.getElementsByTagName("ssn");
theD=document.getElementById("theD");
var stuff="";
for(var i=0;i<names.length;i++)
{
stuff=names.item(i).firstChild.data + "-"+ssn.item(i).firstChild.data;

}
theD.innerHTML+=stuff;
}