title: $.ajax method fails even if controller method gets called and returns proper value. Why am I facing this issue?
body: <p>I am calling one controller method at server side from client as follows:</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "readXML",
      data: data,
      async: false,
      dataType: "xml",
      success: function (result) {
          alert("Call succeeded");
      },
      error: function (result,error) {
          alert("Call failed" + error.Message);
      }
  });
  </code></pre>
  
  <p>The call reached to controller method properly. Controller method does whatever it is supposed to do and returns fine. But once the controller method returns, ajax call immediately goes to error block. What am I doing wrong?</p>
  
  <p>PS. I know that async:false makes the call synchronous and I know my reasons to make this a synchronous call instead of an asynchronous one.</p>
  
  <p>EDIT:</p>
  
  <p>When I used the developer tools in the browser, following is the response:</p>
  
  <p>HTTP status 406:
  The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.</p>
  
  <p>Also, following is my controller method:</p>
  
  <pre><code>@RequestMapping(value = "/readXML", headers={ "Accept=application/xml", "X-Requested-With=XMLHttpRequest" })
  @Produces("application/xml")
  public @ResponseBody Document readSourceXML(@RequestParam("xmlName") String xml_name) {
      Document doc = null;
      try {
          ReadFile rf = new ReadFile();
          doc = rf.getXML(xml_name);
          //test method to check the XML
          //needs to be removed
          printDocument(doc, System.out);
      }
      catch(Exception e){
              //Need to handle the exception
      }
      return doc;
  }
  </code></pre>