Error in JQuery Ajax and Spring mvc driver

0

I am sending a POST from ajax to a controller with Spring mvc, everything worked correctly, the controller received the data and worked with them, the problem has appeared when I wanted to execute a function in the ajax success, I have verified that enter and return error: Not Found, I do not know what can happen because it does not return to success if everything works correctly, I leave the code:

Javascript

 $.ajax({
  type: "POST",
  url: 'http://localhost:8080/HelloSpringMVC/j',
  data: {t: JSON.stringify(objeto), l: JSON.stringify(objeto2)},//put search js object directly here
  success :function(result) {
   // do what ever you want with data

      $("#res2").text("Success");
    pedirDatos();
 }, error: function (xhr, status, error) {
           $("#res2").text(error);
        }
});

Controller

    @RequestMapping(value ="/j", method = RequestMethod.POST)
     public String posted(String t, String l) {
        System.out.println("Tarjetas" +t);
        return "sucess";
}
    
asked by Silvia 11.04.2018 в 18:32
source

1 answer

0

My problem is that it was missing @ResponseBody  @RequestMapping (value="/ j", method = RequestMethod.POST)      public @ResponseBody String posted (String t, String l) {         System.out.println ("Cards" + t);         return "success"; }

    
answered by 12.04.2018 в 12:15