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)

formLogin.on('submit', function(e,errorMessage){
            type: 'POST',
            url: 'loginCheck',
            data: $(formLogin).serialize(),
            dataType: 'json',
            success: function(){ 
                console.log('my message ' + errorMessage);
And here is the code from the Codeigniter controller.

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";               
// $this->cms($errorMessage);

In the console log, I am getting the following message:

my message undefined.

Any help will be deeply appreciated.

Regards, zoreli