Login jquery does not load the page after authentication

Asked

Viewed 49 times

1

please, this function does not load the page. The return is correct, the code enters the if loop, but it does not load the page that should be Location. What can it be?

$('#btnLogin').click(function(){
    var login = $('#inputEmail').val();

    var senha = $('#inputPassword').val();
    
    $.post('_class/login.php',{inputEmail: login, inputPassword: senha}, function(data){
     console.log(data);
      var response = $.trim(data);
          
    	if(data === 'OK'){

        location.reload(true);     	           
      }else{
    	  
    	  $('#myModal').modal('show');
      }
    });
  });

thank you

  • Some parts of the code are still outside the formatting, could you edit the question? :D

  • do console.log(data); and see what you print

  • miguel...has already included the console.log, but still the problem remains. The code is performed, return the user validation, does not open the application and still returns the error. This error should not even appear because it is in "Else"...I edited the post with the console.log(date)

  • there must be some problem in passing the user and password parameters, there the return is not identical to what expects jquery and does not if

  • Where are you using var Sponse? I saw that you do var Sponse = $.Trim(date); and don’t use Sponse. Wouldn’t it be used in if? Give a console.log(Answer) and see the value in it

  • Andre, I don’t know why I can’t see the consolelog (I don’t know how to use it). I’ve made use of Replay in if.... worked out...now that I put on the homologation server does not work. It seems that ta almost solved

  • test in the Chrome browser, with the browser open on the page you want to test press Ctrl+shift+I, will open the inspect elements, click on the "console" tab. Anything you put console.log("something") will appear in this console tab. If you leave it in your console code.log(data) you will see what is in the "date" variable and you will know why it does not fall in if.

  • vlw Andre...now I found myself...after I used your suggested fix in jquery, my dev environment works perfectly. Already on the production server not...by the console the variable is bringing the page code and not a variable value.

Show 3 more comments
No answers

Browser other questions tagged

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