title: Spring MVC controller's ajax method
body: <p>I have some web application that uses jQuery to send AJAX requests to server. One of the methods (in controller) returns a ModelAndView object that can be a html code or JSON object - depends on errors existing. The input parameters of thid method is JSON array (form).
  The method definition:</p>
  
  <pre><code>@RequestMapping(value = "/generate", method = RequestMethod.POST, headers = BaseController.AJAX_HEADER)
  public ModelAndView generate(@RequestBody HandlingReportForm form, HttpServletResponse response) {...}
  </code></pre>
  
  <p>The jQuery method looks like:</p>
  
  <pre><code>jQuery.ajax({
      'type': 'POST',
      'url': url,
      'contentType': 'application/json',
      'data': JSON.stringify(data),
      'dataType': 'json',
      'success': callback,
      error : function(jqXHR, textStatus, errorThrown) {
          alert(errorThrown);
      },
      complete : function(jqXHR, textStatus) {
          alert(textStatus);
      }
  });
  </code></pre>
  
  <p>There is no problem when server returns a JSON array. The problem comes when server's response is html. I receive a "parseerror" exception. I suppose that jQuery trying to parse the response string to JSON. AM I right?
  How can I disable that automatic parsing? Is there another way to implement such universal method?</p>
  
  <p>Thank you
  Thank you</p>