Callback of ajax using Spring MVC does not work

0

Well, I'm trying to make a simple AJAX call (which already works), but callback is not "triggered":

$('#negotiation-status').on('click', '#button-add-destination', function (e){
       var departure =  $('#input-departure').val();
       var arrive = $('#input-arrive').val();
       var ckb = $('#ckb-label').val();
       var price = $('#input-price').val();
       var saleType = $('#ckb-saleType').val();

       $.ajax({
        type:'POST',
        dataType: 'html',
        data: "departure="+departure+"&"+"arrive="+arrive,
        url:'/viatge/auth/addSelectedDestination?${_csrf.parameterName}=${_csrf.token}',
        sucess: function (result){
            alert("Aqui ele funcionou..." + result);
        }, 
        error: function(error){
            alert("Aqui ele deu erro..." + error);
        }
       });
       e.preventDefault();
       return false;
   });

I'm using Spring MVC, below is the method responsible for handling the request and sending a response:

@RequestMapping(value="/addSelectedDestination", method=RequestMethod.POST)
public @ResponseBody String addSelectedDestination(@RequestParam(value="arrive", required=true) String arrive,
        @RequestParam(value="departure", required=true) String departure){

    DestinationRequested destinationRequested = new DestinationRequested();

    destinationRequested.setArrivalDate(arrive);
    destinationRequested.setDepartureDate(departure);

    selectedDestination.add(destinationRequested);

    return arrive + departure;

}

The problem is that alert(); in sucess is not triggered!

    
asked by anonymous 03.11.2014 / 01:12

1 answer

1

It looks like it's a typo, it says success with just a c , when the correct one is success . Remember to check out these details at documentation .

    
03.11.2014 / 18:36