I have the following function:
function Login() {
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
$.post("Login.php", {
username: username,
password:password
}, function(data) {
console.log(data);
});
}
The issue that I'm having is that the function only runs sometimes. I had checked to see if it were a case that JQuery wasn't loaded upon the function running but it was. It doesn't really matter what text I input it simply works only sometimes. I think it has something to do with the $.post
function.
Please see the following snaps of Chrome DevTools:
Sometimes it will do the above and the function will stop/end at line 67.
And other times it will go all the way through & work.
The above image shows me using the same input as the image before but this time the function stops/ends at line 67.
What could be causing this? I don't think it has anything to do with the variables themselves. The function is called when a button is clicked.
Update!
I'm seeing this error in the console. The page is also reloading so maybe before the post request could go through the web page would reload but I don't know how to solve this.