jq ajax success error,Jquery Ajax post success/error function

I have a post function that is not being caught on error.

Heres the value being returned from postride.php.

if ($group_id==0) {

echo No group selected;

return false;

exit;

}

Heres 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!

I have a post function that is not being caught on error. Heres the value being returned from postride.php. if ($group_id==0) { echo No group selected; return false; exit; } Heres 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!
经验分享 程序员 微信小程序 职场和发展