title: How do I call a Spring controller method with Jquery AJAX
body: <p>I have the following Spring Controller </p>
  
  <pre><code>@Controller
  @RequestMapping("/accreq")
  </code></pre>
  
  <p>with the following mapping</p>
  
  <pre><code>@RequestMapping(value = "/defRoles", method=RequestMethod.GET)
  public @ResponseBody String loadDefaultRoles(
      @RequestParam(value="idGroup", required=false) String groupID
      throws ServletException{
  </code></pre>
  
  <p>I'm trying to call this method with the following jquery ajax</p>
  
  <pre><code>$.ajax({
  type: 'GET',
  url: '/accreq/defRoles',
  data: {idGroup: $('#infoGroup').val() },
  success: function() {
      alert("success");
      }
  });
  </code></pre>
  
  <p>Please help me figure out why the Spring method is not being called even though the ajax method is being called when I click a button.  I have stepped through the script with firebug and it definitely hits the ajax function.  </p>