I’m still getting a response back no matter what, I think if I ever redo my trivia game I would use error codes. However for just simple validation this will work:
An I know where the response is going to in JQuery:
[php] var myData = {
‘action’ : ‘save’,
‘username’ : $username.val(),
‘password’ : $password.val(),
‘verify’ : $verify.val(),
‘firstName’ : $firstName.val(),
‘lastName’ : $lastName.val(),
‘emailAddress’ : $emailAddress.val()
};
$.post('ajax.02.php', myData, function(response) {
/* Load json data from server and output appropiate message */
if(response.type === 'error') {
$password.val('');
$verify.val('');
$status.css({
'background-color' : 'red'
});
output = response.text; // Display the error message:
$status.animate({width: 'toggle'}, 350); // Slide the error/success container div down:
displayTimer(12);
} else { // Display to screen if successful:
$status.css({
'background-color' : 'green'
});
$('#register input[type="text"], #register input[type="password"]').each(function() {
$(this).val(''); // Clear input fields:
});
$username.focus(); // Set Focus on first input tag:
output = response.text; // Grab the success message from php:
$status.slideDown(500);
displayTimer(6); // Call Timer and only display it for so many seconds:
}
$message.text(output); // Set the text in the p tag with the result class:
}); // End of Post Data to Server Function:[/php]