Console states the following errors when I hit the submit button on my page:
process.js:19 Uncaught ReferenceError: data is not defined
at HTMLButtonElement.<anonymous> (process.js:19)
at HTMLButtonElement.dispatch (jquery-3.3.1.min.js:2)
at HTMLButtonElement.y.handle (jquery-3.3.1.min.js:2)
This is my jQuery AJAX code that executes when you hit the submit button. This is my first time playing with AJAX/jQuery - not sure what is happening so if someone could help me, that'd be greatly appreciated!
$(document).ready(function() {
$('#login_button').click(function()
{
event.preventDefault();
var formData = {
'email' : $('input[email=email').val(),
'password' : $('input[password=password').val()
};
$.ajax({
type : 'POST',
url : 'ajax/proclogin.php',
data : formData,
dataType : 'json'
});
// using the done promise callback
if (data.success == false)
{
if(data.errors.email)
{
//toastr.error(''+data.errors.email+'', 'Oops!');
alert('Email error');
}
else if(data.errors.password)
{
//toastr.error(''+data.errors.password+'', 'Oops!');
alert('Password Error');
}
}
else
{
//toastr.success('Works!', 'WooHoo!');
alert('Works.');
}
});
});