Probably some simple derp but I just can't figure this out, I'm using almost identical code in a different solution and it works.
Javascript:
$('#drop').click(function(e) {
e.preventDefault();
$('#login').slideToggle(1000);
});
$('#sub').click(function(e) {
e.preventDefault();
$('#info').html('<img src="img/load.gif" />')
$.post('login.php', {user: document.getElementById('user').value, pass: document.getElementById('pass').value}, function(response) {
if (response == 'ok')
{
$('#login').slideUp(500);
$('#info').html('');
$('#joocy').html('<img src="img/load.gif" />').load('manage.php');
}
else if (response == 'error')
{
$('#info').html('Invalid user/pass');
}
});
});
PHP:
if ($row = mysql_fetch_array($result))
{
echo 'ok';
}
else
{
echo 'error';
}
Response is being sent back but the if-clause isn't catching it. typeof() returns string.
EDIT: else if (response === 'error ') // notice the space in the string
This works, can anyone explain why the space is appended to the returnstring?
SOLVED: There was a space after PHP closing tag. Thanks for your time everyone! :)