I have the following script:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
function createUser(username, password) {
$.post('/php/Create_User.php', { username: username, password : password},
function(returnedData){
alert(returnedData);
}).fail(function(error){
alert(error.message);
});
}
</script>
And I am calling it like this:
<form onsubmit="createUser(this.username.value, this.password.value)" method="post">
Username:<br>
<input type="text" name="username"><br>
Password:<br>
<input type="password" name="password"><br><br>
<input type="submit" value="Submit">
</form>
Whenever I submit the form, the function gets called but it keeps going into the .fail block but the error message just says "undefined". I do not know how to print out errors or find out why my post is not returning data from my CreateUser page.