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 8075343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:57:32+00:00 2026-06-05T14:57:32+00:00

What HTTP error code do I need to return to a jQuery ajax that

  • 0

What HTTP error code do I need to return to a jQuery ajax that would work with setting a response method? Using jQuery 1.7.

For example, I have the following code:

var request = $.ajax({
            type: "POST",
            url: "/report/template/save",
            data: formData,
            success: function() {

            },
            statusCode: {
                400: function() {
                  $('#template_form .ajax-msg').show();
                  $('#template_form .ajax-msg').html('<strong>Sorry, save failed.');
                }
            }
        });
request.fail(function(data) {
            $('#template_form .ajax-msg').show();
            $('#template_form .ajax-msg').html('<strong>Sorry, save failed.');
        });

I can indeed verify a 400 is being returned.

If the form doesn’t validate server-side, I’ve tried returning both a status 500 and 400 with no luck. Instead what happens is that the code is halted and the .ajax-msg doesn’t display anything. What is $.ajax expecting? Thanks!

  • 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-05T14:57:34+00:00Added an answer on June 5, 2026 at 2:57 pm

    There were multiple conflicts present and thanks to the comments I was able to sort through it.

    First, there were too many success handlers (and in my opinion the naming is a little ambiguous). I removed statusCode and replaced with request.fail and request.always which allowed me to do actions with each response anyways.

    Second, the code wasn’t actually halting but I mistakenly screwed up on a selector and $('#template_form .ajax-msg') was changed to '$('.modal .ajax-msg').

    I hope that helps future problems!

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

Sidebar

Related Questions

I have the following code that returns HTTP error 400 everytime I try to
http://php.net/manual/en/mysqli.init.php $ConnectionResource = mysqli::init(); The above code fails with: Fatal error: Non-static method mysqli::init()
I need to pass the response from ajax call to a jquery template.The response
I need to load a part of code dinamically by using Jquery and Json.
I would like to manually send an HTTP 40x error code to client from
this is my code <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js></script> <script src=http://jquery-translate.googlecode.com/files/jquery.translate-1.3.7.min.js></script> <script type=text/javascript> jQuery(function($) { //when DOM
In many cases in web applications you would need to return an error message,
Here is my code in my jquery/javascript that is performing the ajax request... else
I'm trying out the code at http://www.scala-lang.org/node/112 and I'm getting a match error for
I'm trying to get http://www.gelens.org/code/gevent-websocket/ running and keep getting the following error. socket_id=1 already

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.