I got a problem with my Code. I have a form for a password reset and an AJAX function which leads the inserted mail to a PHP file. To increase the usability of my form I bound a click on enter to my function. By doing a mouseclick on the button anything works fine. By clicking enter the error-part of my ajax fires, but I don't even get an error message.
I use the same principle on a login form and anything works fine, so I am really confused.
That's my code:
// binding keypress enter
$('#modal-pw-reset').on('keypress', function(e) {
if(e.keyCode==13) {
$('#pw-reset-send').trigger('click');
}
});
// password reset
$("#pw-reset-send").click(function() {
var email = $("#pw-reset-email").val();
if (email.length != 0) {
$.ajax({
url: 'my php file to check the email',
method: 'post',
data: {
send: 1,
email: email
},
dataType: 'json'
}).done(function(response) {
console.log('success');
}).fail(function(xhr, status, error) {
console.log(xhr);
});
}
});