I am trying to make a ajax request to check the database if this username is available, but when trying to run the script in the console it give me an error that the is an Uncaught SyntaxError- Unexpected Identifier. I have checked my code but can not find the problem. Can someone please help me figure this out?
Here is my code.
main.js
$('#checkusername').keyup(function() {
$.ajax({
var username = $('#checkusername').val();
url: 'usernamecheck-validate.php',
type: 'POST',
data: {checkusername: username},
success: function(data){
$('.status').html(data);
}
});
});
register.php
<form action="#" method="POST">
<input type="text" name="email" id="email" class="form" placeholder="Enter Email"><br><br>
<input type="text" name="username" id="checkusername" class="form" placeholder="Enter Username"><br><br>
<input type="password" name="password" id="password" class="form" placeholder="Enter Password"><br><br>
<input type="submit" name="register-validation-button" class="form-btn" value="Register Account">
</form>
var username = ...statement inside an object ({}).