Error in comparison with response

Asked

Viewed 49 times

0

I have this JS below, that I include it at the end of my document. It sends the data via ajax to a PHP file that answers a text, in the example below -666 and -log in.

It happens that it does not fall in the right condition. I see through the returned data and does not fit. It started recently, I know this is not normal to hear, but yes, it started less than 5 days from the delivery of the application.

Look at:

$(document).ready(function() {
    //enviando form
    $( document ).on( "click", "#bt_send", function() {
                f_submit();
    }); 
    function f_submit(){
        $('#message').html('<center><span style="color:#0091ea;"Processando</span></center>');
        var form_data = {
            email: $('#email').val(),
            senha: $('#senha').val(),
            is_ajax: 1
        };
        $.ajax({
            type: 'POST',
            data: form_data,
            url: 'php/acesso/login.php',
            success: function(response)
            {
                $('#message').html(response);
                switch (response)
                {                
                  case "-logar": 
                       $('#message').html('<span style="color:#00c853;"><center>Bem Vindo. Carregando permissões.</center></span>');
                       window.location = 'painel.php';
                       break;
                  case "-666": 
                       $('#message').html('<span style="color:#dd2c00;"><center>E-mail ou senha incorreto.</center></span>');
                       break;
                  default: 
                       alert(response);
                       break;
                }
            }
        });
    }
});
  • Welcome Maicon Martins, you’ll get better answers if you give people code that they can use to reproduce the problem. https://answall.com/help/mcve

  • Make a console.log(Answer) in the successful callback and put the result

  • put the console.log(response)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.