I'm using Ajax to call a php site, but I want to do something "on success" and "on error".
By now, this is my js:
$("#votePositive").click(function(){
var idEntrada = $('.entry').attr('id');
var url = "{{ path('moderar_entrada_votacion') }}";
var eleccion=1;
$.ajax({
type: "POST",
url: url,
data: {
idEntrada: idEntrada,
eleccion: eleccion
},error: function(){alert("eee")}, success: function(){alert("bbb")}
});
});
So this is my php code (just a return, just want to try if the connection works)
return true
But my site popups the alert "eee".
I've tried to:
return false
But same is happening, eee alert is comming up.
If I just remove the "return" statment from the php file, it shows up the "bbb" alert.
How can I deal with those returns? How can I tell Ajax that it went OK or Not?