The URL ../../php/users-profs/tryEmail.php
will be interpreted relative to the user's current URL, not the URL of the .js
file. Match the URL in $.post()
to the URL where you will invoke this script, and it will be fine.
Edit based on comment: Add a slash: /php/users-profs/tryEmail.php
-- without it, it's a relative URL, so it's looking in the wrong place.
Also, you need to remove the anonymous wrapper function, because you can't return an anonymous function, and it won't execute anyway. Your code should look like this:
function tryEmail(email)
{
console.log("function:tryEmail, param: " + email);
$.post("/php/users-profs/tryEmail.php", // fixed the leading / here
{
email:email
},
function(data)
{
console.log("function:tryEmail-post, data: " + data);
if(data == "valid")
return true;
else
return false;
});
}