I have a post function that is not being caught on error.
Here’s the value being returned from postride.php.
if ($group_id==0) {
echo 'No group selected';
return false;
exit;
}
Here’s the jquery code:
$(document).ready(function(){
$('#postride').submit(function(event) {
event.preventDefault();
dataString = $("#postride").serialize();
$.ajax({
type: "post",
url: "postride.php",
data:dataString,
error: function(returnval) {
$(".message").text(returnval + " failure");
$(".message").fadeIn("slow");
$(".message").delay(2000).fadeOut(1000);
},
success: function (returnval) {
$(".message").text(returnval + " success");
$(".message").fadeIn("slow");
$(".message").delay(2000).fadeOut(1000);
//setTimeout( function() { top.location.href="view.php" }, 3000 );
}
})
return false;
});
});
The post function returns false, but the error function does not fire, only the success function. It will post “No group selected success”.
Thanks for any help!
The error option in jQuery ajax methods is for errors caused by a bad connection, timeout, invalid url, things of that nature. It’s not the kind of error that you’re thinking.
What most people do is something like this…
php
javascript