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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:49:05+00:00 2026-05-30T03:49:05+00:00

When a user submits invalid data to my API (usually via Javascript + JSON),

  • 0

When a user submits invalid data to my API (usually via Javascript + JSON), I am wondering which HTTP response code I should reply with.

Should I return a HTTP 200 response with the errors – or should my server respond with a 400 or 500 error since the request actually failed my validation because of some bad data?

It seems like a 400 error is the way to go since “The 4xx class of status code is intended for cases in which the client seems to have erred” – wikipedia

However, one thing to keep in mind is that most people use a framework like jQuery which requires you to specify an alternate callback when AJAX requests respond with any status code other than a 200.

  • 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-30T03:49:07+00:00Added an answer on May 30, 2026 at 3:49 am

    400 Bad Request The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

    use statusCode in jquery ajax calling:

    <html>
    <head>
    <title>jquery testing</title>
    <script type="text/javascript" src="jquery-1.6.2.min.js"/>"></script>
    <script language="javascript">
    $(document).ready(
        function(){
            $('#linkClick').click(
                function(){
                        $.ajax({
                            url: 'a.html',
                            data: {},
                            type: 'get',
                            dataType: 'json',
                            statusCode: {
                                404:function() { alert("404"); },
                                200:function() { alert("200"); },
                                201:function() { alert("201"); },
                                202:function() { alert("202"); }
                            },
                            success: function(data) {
                                alert( "Status: " + data);
                            }
                        });
                    }); 
            }
            );
    </script>
    </head>
    <body>
    <a href="#" id="linkClick">click</a>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF web service which throws exceptions when invalid data is submitted.
I have this code which posts data to a page and returns data. This
I have form where user submits field. Field can have letters, numbers, and punctuation.
After a user submits a form, how do you detect that the form has
So the chain of events is: The user submits a form. During the processing
I have situation like this: user submits form with action='/pay' in '/pay' I have
I'm trying to user Facebooker to publish stories to Facebook. When a user submits
I want to run a particular block of PHP if the user submits a
I'm building a tagger. After a user submits a tag, ajax returns: {returnmessage:The Ajax
I'm trying to figure out how to show validation errors after a user submits

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.