title: 500 Internal Server Error when calling ajax in spring
body: <p>I am using Spring MVC and I have an AJAX which is used to delete selected user. It's working fine on my local system but when I tried to run the same code on development server I'm getting </p>
  
  <blockquote>
    <p>500 Internal Server Error</p>
  </blockquote>
  
  <p>I did google to figure out what is wrong with my code but I'm not able to figure out anything till now. Any help will be appreciated.</p>
  
  <p>AJAX function in my JSP file:</p>
  
  <pre><code>$('.del-btn .userId').click(function(){
      var userId = $(this).attr("alt");
      var data = 'userId='+ userId;
      $.ajax({
          type: 'POST',
          url: '${pageContext.servletContext.contextPath}/deleteUser',
          data: data,
          success: function(response) {
              $('#submitkpi').submit();
          }
      });
  });
  </code></pre>
  
  <p><code>deleteUser</code> function in Controller:</p>
  
  <pre><code>@RequestMapping(value = "/deleteUser", method = RequestMethod.POST)
  public @ResponseBody Map&lt;String, ? extends Object&gt; deleteKpi(@ModelAttribute(value = "userId") String userId, BindingResult result) {
  
      if (!userId.isEmpty()) {
          userService.deleteUser(userId);
          return Collections.singletonMap("ok", true);
      }
      return Collections.singletonMap("errorMsg", "Unable to complete your request!");
  }
  </code></pre>