.ajax() Not Reading Returned XML Data

.ajax() Not Reading Returned XML Data

Hello everyone. 

The request is being made successfully to the server. The server is returning the xml data because I see it in Firebug. It returns a string that is a copy of the page and at the end it has my xml data. So the return info looks like this:

<html>

//copy of full page plus scripts

</html><?xml version="1.0" encoding="utf-8"?><comments> (all of the xml data) </comments>

Why it's returning a string, I'm not sure because I send the header info too in the php code:

header('Content-Type: text/xml');
echo $xml;

The ajax call is simple:

  1. $.ajax({
  2.    url:pageloc,
  3.    type: "post",
  4.    data: dataobjnew,
  5.    dataType: 'xml',
  6.    success: function(xml) {
  7.          alert(xml);
  8.    }
  9. });

Any idea on what's going on?