So I'm building a forgot password system, and I would like the Forgot Password div to execute the forgotpassword php script when it is clicked. Note: all files are in the same directory I so far have: In HTML
<div id="forgotpass" href="" onclick="fpass()">forgot your password?</div>
In my Javascript file:
function fpass() {
console.log("fpass function");
$.ajax({
type: "POST",
url: 'forgotpass.php',
success: function(data){
//data returned from php
//console.log(data);
}
});
}
Inside the php script I have a few echo statements so far to test if the script actually gets run.
However, when I click "forgot your password?" it runs fpass() and alerts "fpass function" so I know the function works. But I don't think its executing the php script. I'm new to this so can anyone provide me an explanation as to why the php script isn't getting executed. Do I need to put anything inside the php script? Thanks!