I have the following function in jQuery code:
btnLogin.on('click', function(e,errorMessage){
console.log('my message' + errorMessage);
e.preventDefault();
return $.ajax({
type: 'POST',
url: 'loginCheck',
data: $(formLogin).serialize(),
dataType: 'json'
}).promise();
console.log('my message' + errorMessage);
});
WHAT I AM TRYING TO DO: I am trying to console.log the error message. I am getting undefined if the console.log line is above the ajax function, and nothing if the console.log is bellow of it.
Can anyone tell me how to get the value of the errorMessage displayed in this or another new function?
Also, any link with about using Ajax for checking php login form will be deeply appreciagted
Regards,Zoran