I have this simple Ajax code, my question is only, what does data.logged return, and what i need to have in the logged.php file…
I’m new to ajax, sorry for the dumb question…
$.ajax('logged.php', {
data: {
login: login,
pass: pass
},
success: function(data)
{
if (data.logged)
{
setTimeout(function() {
document.location.href = 'index.php'
}, 2000);
}
else
{
setTimeout(function() {
formLogin.clearMessages();
displayError('Utilizador ou password errados');
}, 2000);
}
},
error: function()
{
formLogin.clearMessages();
displayError('Error while contacting server, please try again');
}
});
On the client side, adding
dataType : 'json'worked for me.And then on the server side: