I'm pretty new to PHP, and I'm currently using AJAX to validate a form upon a button click.
Currently, I'm using an if statement to see whether to continue on to the next page of a multi-step form or not.
$.ajax({
url: 'index.php',
type: 'POST',
data: {
myid: 1,
action: action,
username: user,
password: pass
},
success: function(data){
if (data == "continue") {
wizard.next(wizard);
wizard.showButtons();
} else {
helpframe.text(data);
helpframe.show();
}
}
});
I'm wondering when to simply use an if statement like above in the return AJAX function vs. throwing an error in PHP, since it's my understanding that you can somehow use code to purposely cause PHP to throw an error and then execute different code upon a "failure".