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!