I'm implementing a feature on a site run on a local server where it checks actively whether a username is available or not. The problem is that $.get() seems to not work at all and isn't calling the corresponding app.get() function.
script.js:
$('#username').keyup(function() {
var username = $('#username').val();
$.get('/getCheckUsername', {username: username}, function(result) {
alert('Query done.') //just to test that it has been called
alert(result);
})
})
No alerts are showing up on any keystroke on the page.
routes.js:
app.get('/getCheckUsername', signupController.getCheckUsername);
signUpController:
getCheckUsername: function(req, res) {
var username = req.query.username;
database.findOne(User, {username: username}, 'username', function(result) {
res.send(result);
});
}