Hi
I am trying to build Ajax & Codeigniter login form. My first objective is if the user enter wrong username or password, to inform him with jquery, without relaoding the page. But after the ajax call, I am getting undefined in the console instead of my error message. Here is the code from the JavaScript (jQuery)
And here is the code from the Codeigniter controller.Code:formLogin.on('submit', function(e,errorMessage){ $.ajax({ type: 'POST', url: 'loginCheck', data: $(formLogin).serialize(), dataType: 'json', success: function(){ console.log('my message ' + errorMessage); } }); e.preventDefault(); });
In the console log, I am getting the following message:PHP Code:
if .....
// the code that checks for the username and password against the database and user is found....
else {
// user is not found, so populate the error message....
$errorMessage = "Wrong Username or Password";
echo json_encode($errorMessage);
// $this->cms($errorMessage);
}
my message undefined.
Any help will be deeply appreciated.
Regards, zoreli



Reply With Quote


Bookmarks