Reputation: 1433
So this is the third time this login system has worked a full day, then when I go to use it the next day it just stops working. I wasn't working on this page or any files that relate to it so it really makes no sense. I'm extremely frustrated. So this is the jQuery
code for the login.
$('#sign_in_form').submit(function (e) {
var email = $('#email').val();
var password = $('#password').val();
$.post('sign_in.php', { email: email, password: password })
.done(function(data) {
if(data == 'FSI') {
window.location = 'accounts.php';
} else {
$('#errors').text(data);
}
})
.fail(function(jqXHR, status, error) {
$('#errors').text(error);
});
e.preventDefault();
});
Now #errors is a div right above where you enter your email and pw. It will tell you multiple response from the php file if you enter the wrong info. Well if you enter the right info FSI comes back and you are directed to the accounts page as shown. Well right now in the #errors div there is a message saying 'FSI'. I am so confused, if data == 'FSI' then it should be directing the user to accounts.php should it not?
This is silly, this code is so simple it should never fail. The day before yesterday it worked and then stopped yesterday and I had to enter e.preventDefault();
. Now its something new, I feel like tomorrow it might be something else. Arg, any help is appreciated, sorry for the rage.
Upvotes: 0
Views: 133
Reputation:
White space can kill you here. Make sure there are no leading/trailing space characters. Try
if ($.trim(data) == 'FSI') {...}
Also try
console.log(data.length)
Upvotes: 4