AJAX DOM PARSER help?

RACHEL

New member
This code is to Parse form a server some XML. have tried everyhting thing it needs a new pair of eyes any help would be great
<html>
<head>
<script type='text/javascript' src='http://edward/ajax/prototype.js'> </script>
<script type='text/javascript'>

function request()
{
var a = document.getElementById('origin').value;

var request = new Ajax.Request
('http://edward.solent.ac.uk/~FoshRachel/webservice.php',
{ method: 'get',
parameters: 'origin=' + a,
onComplete: resultsReturned }
);
}

function resultsReturned (xmlHTTP)
{
var trainsArray = xmlHTTP.responseXML.getElementsByTagName("train");

var html ="";
for(var count=0; count<trainsArray.length; count++)
{
var destination = trainsArray[count].getElementsByTagName("destination")[0].
firstChild.nodeValue;


html = html + "Origin : " + origin + "destination :" + destination + "<br/>";

}
document.getElementById("results").innerHTML = html;
}

</script>

<style type='text/css'>

#results
{
border-style: ridge;
border-color: green;
border-width: 5px;
background-color: #fffff0;
width: 800px;
height: 400px;
overflow: auto
}

</style>

</head>
<body>
<h1> Welcome to CHOO CHOO trains!</h1>
<br/>
<h2>The UK's premier train site for european rail travel</h2>
<br/>

<label for ="origin"> ORIGIN:</label>
<input name="origin" id="origin" /><br/>


<label for ="destination"> DESTINATION:</label>
<input name="destination" id="destination" /><br/>


<br/>
<input type='button' value='Go!' onclick='request()'/>
<div id='results'></div>



</body>
</html>
 
Back
Top