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

  • SEARCH
  • Home
  • 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 8869545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:30:11+00:00 2026-06-14T17:30:11+00:00

I have an ajax form where I have defined some ajaxOptions variable and pass

  • 0

I have an ajax form where I have defined some ajaxOptions variable and pass that to Ajax.BeginForm:

var ajaxOptions = new AjaxOptions
                      {
                          HttpMethod = "POST",
                          LoadingElementId = "loading",
                          OnBegin = "Base.loadingButton('#RegisterSubmit');",
                          OnSuccess = "Register.onSuccess",
                          OnFailure = "Base.onError"
                      };

All JavaScript functions are defined in a special namespace such as Base, Register,… .

Now when form submit and in server a error with Code: “0” and Type: “Sql” occurs and logged with elmah, and Status Code: “HTTP/1.1 302 Found” returned from server.

Question 1:
OnSuccess function fired always even at this case which status 302 returned (but OnSuccess only must fire when status code is 200!!!),why?

Question 2:
sometimes OnSuccess function never fire even status code is 200!!!,why?

  • 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-06-14T17:30:12+00:00Added an answer on June 14, 2026 at 5:30 pm

    Question 1: OnSuccess function fired always even at this case which
    status 302 returned(but OnSuccess only must fire when status code is
    200!!!),why?

    That’s because when you perform an AJAX request to a server side script which redirects (status code 302), AJAX follows the redirect to the target location and eventually ends up with status code 200 => the OnSuccess will be fired because the request succeeds. There’s not much you could do about it – it’s how AJAX works – you cannot intercept 302 status code.

    Are you using this to detect a redirect to the login page scenario? In case the session expires or something? The proper way to handle this scenario is to use 401 status code from the server and detect this event in the OnFailure method. In order to prevent the FormsAuthentication module redirecting to the LogOn page but send 401 status code instead you may take a look at the following article.

    Question 2: sometimes OnSuccess function never fire even status code is 200!!!,why?

    OnSuccess should always fire if the status code is 200, unless you have some javascript errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Ajax form that updates a div when submitted with a submit
I have an Ajax contact form that links to a jquery file but for
I have a small jQuery plugin that I use for form AJAX validation. There
i have the following javascript to post a form through ajax without refreshing the
I'm encountering a problem whereby i have fields in a form that has variable
I have a form that contains a Part Number inputText field and some other
I have an AJAX based application that updates a text field in a form
I have a form that I load into a popover via ajax. The form
I would like to have Ajax form in Rails so i'm using form_remote_tag. The
I have an ajax form in asp.net mvc which is as simple as this:

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.