0

Okay... so I have the following code in an external JS file to check if a user currently exists on a MySQL based on their email:

function checkuser(email)
{

        $.post('scripts/php/usercheck.php', 
            { 
                "eaddr" : email 
            },

            function(data)
            {
                return data;
            }

              );


}

But, to test for simplicity sake, I put just this in my PHP file to test the function's capabilities:

<?php
echo 1;
?>

And from my main HTML file, I call this:

//Some code...//
<script type="text/javascript" src="./scripts/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="./scripts/myjs.js"></script>

//Some code...//

<script type="text/javascript">
alert(checkuser(document.getElementById('eaddr').value));
</script>

Now, the above code doesn't show it, but the alert only happens when a button is clicked, and eaddr is a legitimate field on the form and whatnot. Yet, every time my code executes, it returns 'undefined'. I thought this code should work... no? I know I'm probably overlooking something small and stupid, but could someone help me out as to what might be wrong? This function is very important to my project. Thanks in advance!

Nickersoft
  • 684
  • 1
  • 12
  • 30

0 Answers0