My problem is that I want to return the xml file from the server back to the client and parse it using jQuery jQuery. This is the code:
Client:
$("#submit").click(function(){ $.ajax({ type: "POST", url: "search.php", data: "whatever", dataType: "xml", async: false, success: function(xml){ var data = $('doctor',xml).text(); alert(data); } }); });
Server (php file),
header('Content-type: text/xml'); echo '<?xml version="1.0" encoding="utf-8"?>'; echo "<tables>"; echo "<doctor>Someone</doctor>"; echo "</tables>";
I have an empty warning and I donβt know why ??
ok i found it. my php file was in this form
//some code include("other.php"); //some other code
where the other.php file was the file that I posted above. I cut / paste the header so the last php file is
//some code header('Content-type: text/xml'); include("other.php"); //some other code
and other.php
echo '<?xml version="1.0" encoding="utf-8"?>'; echo "<tables>"; echo "<doctor>Someone</doctor>"; echo "</tables>";
Now it works fine. Thanks for your quick answers!
source share