Here is my code in my jquery/javascript that is performing the ajax request...
else {
$.post("http://www.example.com", {email: val},
function(response){
finishAjax('email', response);
});
}
joinAjax('cemail');
}
if (id == 'cemail') {
$('#cemailMsg').hide();
var email = $('#email').val();
if (errors.email == false) {
if (val != email) {
The ajax request is working and all is good, but the next if statement where the argument is:
if (errors.email == false) {
I need to be able to set this variable from my ajax.php file to either true or false and return it so the javascript can read it. Is this possible?? It is because the ajax is checking if the username is available or not, if not available a form error would be true preventing the form submitting, or if false then the user can submit.
My ajax.php file:
if ($_REQUEST['email']) {
$q = $dbc -> prepare("SELECT email FROM accounts WHERE email = ?");
$q -> execute(array($_REQUEST['email']));
if (!$q -> rowCount()) {
echo '<div id="emailMsg" class="success">Email OK</div>';
exit();
}
else {
echo '<div id="emailMsg" class="error">Email taken</div>';
exit();
}
}