title: Spring Controller + Ajax return String
body: <p>I want to return String from <code>Spring MVC Controller</code> to <code>Ajax</code>.
  It is not working as expected and gives error.</p>
  
  <p>My Ajax codes for this:</p>
  
  <pre><code>function ajaxRequest(item) {
  
      $.ajax({
          type: "POST",
          url: "/myPage",
          data: {
             item: item
          },
          success: function (html) {
  
              alert(html);
          },
          error: function(e) {
              console.log("Error:" + e);
          }
      });
  
  }
  </code></pre>
  
  <p>My Controller:</p>
  
  <pre><code>@RequestMapping(value = "/myPage", method= RequestMethod.POST, produces="text/plain")
  public @ResponseBody String myController(HttpServletRequest request) {
  String myItem = request.getParameter("item");   
  
  ...
  
  return myItem + "bla bla bla";
  }
  </code></pre>
  
  <p>Chrome console result:</p>
  
  <pre><code>POST http://localhost:8080/myPage 406 (Not Acceptable) jquery.js
  Error:[object XMLHttpRequest] 
  </code></pre>
  
  <p>What am i missing here?</p>