I hope you can help me. I am working on a web project in php and ajax of JQUERY the problem I have is in the following code:
$.ajax({
url: ruta,
type: 'POST',
data: img,
contentType: false,
processData: false,
})
.done(function(res) {
if(res==="a"){
$("#error-img").html("Error, el archivo no es una imagen");
$("#error-img").addClass('text-danger');
}else if(res==="b"){
$("#error-img").html("Error, el tamaño máximo permitido es un 1MB");
$("#error-img").addClass('text-danger');
}else if(res==="c"){
$("#error-img").html("Error, el tamaño máximo permitido es un 1MB");
$("#error-img").addClass('text-danger');
}else if(res==="d"){
$("#error-img").html("Error la anchura y la altura maxima permitida es 500px");
$("#error-img").addClass('text-danger');
}else if(res==="e"){
$("#error-img").html("Error la anchura y la altura mínima permitida es 60px");
$("#error-img").addClass('text-danger');
}else{
$("#error-img").html("Imagen subida con exito");
$("#error-img").addClass('text-success');
}
});
The php file returns a string to me, what I want is to compare it by means of if () but it does not do it, it only launches the else and it does not compare, someone can tell me why I can not. I HAVE A SUSPICION THAT MAY BE FOR THIS:
contentType: false,
processData: false,
Please, I hope your quick help I'm going crazy