title: Ajax call to spring boot controller to redirecting a view
body: <p>I'm new to spring boot framework. 
  I have a jQuery method that gets called upon the click of a span element. In that jQuery method, I have an ajax call which makes a call to the spring boot controller and passes a string as a parameter. The controller is getting the parameter passed from the ajax call. But it is not redirecting to a different view. The different view is an html page called <strong>ajaxView.html</strong>. I want to add an attribute to the view as well. Any help would be great. </p>
  
  <p>Here's my ajax call: </p>
  
  <pre><code>$(document).ready(function() {
  $('.spanClass').on('click', '#id_1', function(event){   
       event.stopPropagation();
  
           var str = ((event.target.parentElement).parentElement.href);
              $.ajax({
                  type: 'POST',
                  url: "http://localhost:8080//span/view?term="+encodeURIComponent(str),
                  contentType: 'text/plain',
                  crossDomain: false,
                  async:true,
                  success:function(response) {        
                  }
              });
    });
  });
  </code></pre>
  
  <p>Here's my controller method:</p>
  
  <pre><code>@RequestMapping(method=RequestMethod.POST, value = "/span/view")
  public @ResponseBody ModelAndView redirectAjax(String term, Model model) {
  
      Employee emp = new Employee();
      emp.setName(term);
  
      model.addAttribute("employee", emp);
  
      return new ModelAndView("redirect:/ajaxView");
  
  }
  </code></pre>