I want to load a xml file using Jquery . The xml is generated using a php script (Currently just using echo) My problem is that the file will just not produce and results . My Jquery is listed below
$(document).ready(function()
{
$.ajax({
type: "GET",
url: "phpxml.php",
dataType: "xml",
success: displayXml
});
function displayXml(data){
$(data).find("sites").each(function() {
var heading = $(this).find("name").text();
var output = "<li>";
output += "<h2>" + heading + "</h2>";
output += "</li>";
$("#place-holder").append(output);
});
}
}); // doc ready
</head>
<body>
<h2> Ajax / Jquery Test </h2>
<ul id='place-holder'>
</ul>
</html>
My php file is below which just echos xml. Can anyone offer any suggestions please ?
<?php
echo '<?xml version="1.0" encoding="iso-8859-1" ?>';
echo"
<sites>
<name>
J Smith
</name>
<name>
A Coxhead
</name>
<name>
D Wilson
</name>
</sites>
" ;
?>