Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6570187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:43:29+00:00 2026-05-25T14:43:29+00:00

I have a post function that is not being caught on error. Here’s the

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:43:30+00:00Added an answer on May 25, 2026 at 2:43 pm

    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

    if ($group_id == 0) {
    echo json_encode(array(
        'status' => 'error',
        'message'=> 'error message'
    ));
    }
    else
    {
    echo json_encode(array(
        'status' => 'success',
        'message'=> 'success message'
    ));
    }
    

    javascript

    $(document).ready(function(){
    $('#postride').submit(function(event) {
         event.preventDefault();
         dataString = $("#postride").serialize();
         $.ajax({
            type: "post",
            url: "postride.php",
            dataType:"json",
            data: dataString,
            success: function (response) {
                if(response.status === "success") {
                    // do something with response.message or whatever other data on success
                } else if(response.status === "error") {
                    // do something with response.message or whatever other data on error
                }
            }
        })
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a form that is not being read by serialize() function. <script type=text/javascript> function
I have a jQuery post function that returns a response on success after the
I have this function from a plugin (from a previous post) // This method
I have code as follows: $(#item_select).change(function() { var params = $(#item_select option:selected).val(); $.post('/account/ar_form.php', {idata:
Here's a bit of javascript taken from this reddit post : function Stream() {
I have a php function that's run when a build.php page is loaded and
I have written a form using the jQuery .post() function to post the data
I have the following code: <script type=text/javascript> $(document).ready(function() { $(#Save).click(function() { $.post(url, { data:
I Have the following function. function ChangeDasPanel(controllerPath, postParams) { $.post(controllerPath, postParams, function(returnValue) { $('#DasSpace').hide(slide,
I have a controller insert action: <AcceptVerbs(HttpVerbs.Post)> _ Function InsertObject(<Bind(Exclude:=Id)> <ModelBinder(GetType(CustomModelBinder))> ByVal object As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.