title: Spring & jQuery: AJAX call can't find path to Controller function
body: <p>Ok so I'm submitting a simple form to my Spring Controller through jQuery. Here is the code:</p>
  
  <pre><code>&lt;form id="addNote" role="form" action="addNote" method="POST"&gt;
          &lt;div class="form-group error"&gt;
              &lt;label for="note"&gt;Enter your Note &lt;/label&gt;
              &lt;textarea rows="3" cols="50" name="note" class="form-control"
                  id="note"&gt;&lt;/textarea&gt;
          &lt;/div&gt;
          &lt;div class="alert alert-danger" style="display: none"&gt;
              &lt;strong&gt;Error!&lt;/strong&gt; Text length must not exceed 100 characters
          &lt;/div&gt;
          &lt;button type="submit" class="btn btn-default"&gt;Save Note&lt;/button&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>$(document).ready(function(){
      $("#addNote").submit(function(e){
          e.preventDefault();
          var formObj = $(this);
          var formURL = "addNote";
          var formData = $("#note").val();
          $.ajax({
              url: formURL,
              type: 'POST',
              data: formData,
              success: function(response){
                  alert(response);
              },
              error: function(response){
  
              }
          });
      });
  });
  </code></pre>
  
  <p>And the Controller method:</p>
  
  <pre><code>@RequestMapping(value="/addNote", method=RequestMethod.POST)
  public Vector&lt;String&gt; addNote(Locale locale, Model model, HttpServletRequest httpServletRequest, HttpSession httpSession){
      String note = httpServletRequest.getParameter("note");
      notes.add(note);
      ModelAndView mv = new ModelAndView("notes");
      mv.addObject("thenotes", notes);
      return notes;
  }
  </code></pre>
  
  <p>I need to return the <code>notes</code> object to the jQuery so that I can display it's data as output. But this is the error I'm getting in the Chrome console:</p>
  
  <p><a href="https://i.stack.imgur.com/TXV63.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TXV63.png" alt="enter image description here"></a></p>
  
  <p>So apparently there is a problem in the path. I have tried changing <code>var formURL = "addNote";</code> to <code>var formURL = "assessment/addNote";</code> in the jQuery but it doesn't work. </p>
  
  <p>But for some reason if I change return value of <code>addNote()</code> function in the Controller to <code>ModelAndView</code>and return <code>mv</code> then it works but it's not the response in the jQuery I need.</p>