title: return xml in jquery ajax
body: <p>My problem is that I want to return an xml file from server back to client and parsing it using ajax function of jquery. This is the code:</p>
  
  <p>Client:</p>
  
  <pre><code>$("#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);
          }
      });
  });
  </code></pre>
  
  <p>Server(php file),</p>
  
  <pre><code>header('Content-type: text/xml');
  echo '&lt;?xml version="1.0" encoding="utf-8"?&gt;';
  echo "&lt;tables&gt;";
  echo "&lt;doctor&gt;Someone&lt;/doctor&gt;";
  echo "&lt;/tables&gt;";
  </code></pre>
  
  <p>I have a blank alert and I do not know why??</p>
  
  <p><hr>
  ok I found it. my php file was in this form</p>
  
  <pre><code>//some code
  include("other.php");
  //some other code
  </code></pre>
  
  <p>where the other.php file was the file I posted above. I cut/paste the header so the final php file would be </p>
  
  <pre><code>//some code
  header('Content-type: text/xml');
  include("other.php");
  //some other code
  </code></pre>
  
  <p>and other.php</p>
  
  <pre><code>echo '&lt;?xml version="1.0" encoding="utf-8"?&gt;';
  echo "&lt;tables&gt;";
  echo "&lt;doctor&gt;Someone&lt;/doctor&gt;";
  echo "&lt;/tables&gt;";
  </code></pre>
  
  <p>now it works perfect. Thanks for your quick replies!</p>