In a php script, after an attempt at a database insert, I'm returning to the calling $.ajax() function either the id of the new record or an error message:
if ($newID > 0) {
// Successfully added new record
echo $newID;
} else {
// No new record was inserted
echo 'Error: ' . mysqli_error($dbc);
}
My question is: if the php else clause gets fired and I'm passing a string via the echo, then won't the success() function be called in the $.ajax function? Is there a way to somehow "fire" the $.ajax error() function depending on what's passed from the php script?