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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:52:10+00:00 2026-05-20T03:52:10+00:00

My project is returning JSON to Ajax calls from the browser. I’m wondering what

  • 0

My project is returning JSON to Ajax calls from the browser. I’m wondering what the proper status code is for sending back with responses to invalid (but successfully handled) data submissions.

For example, jQuery has the following two particular callbacks when making Ajax requests:

success: Fired when a 200/2xx status code is delivered along with the response.

error: Fired when 4xx, 5xx, etc, status codes come back with the response.

If a user attempts to create a new “Person” object, I send back a JSON representation of the newly created object upon success, thus giving javascript access to the necessary unique ID’s for the new object, etc. This, of course, is sent with a 200 status code.

If a user submits malformed or invalid data (say, an invalid/incomplete “name” field), I would like to send back the validation error messages via JSON. (I don’t see why this would be a bad thing).

My question is: in doing so, should I send a 200 status code, because I successfully handled their invalid data? Therefore, I’d be using the jQuery success callback, but simply check for errors…

Or, should I use a 4xx status code, perhaps ‘Bad Request’, because the data they sent me is invalid? (and thus, use the error callback to do the necessary client-side notifications).

  • 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-20T03:52:10+00:00Added an answer on May 20, 2026 at 3:52 am

    I agree with the 400 Bad Request response.

    For inspiration you could have a look at how Twitter (widely used JSON service) does this:
    https://dev.twitter.com/overview/api/response-codes

    Code Text Description

    • 200 OK – Success!
    • 304 Not Modified – There was no new data to return.
    • 400 Bad Request – The request was invalid or cannot be otherwise served. An accompanying error message will explain further. Requests without authentication are considered invalid and will yield this response.
    • 401 Unauthorized – Missing or incorrect authentication credentials. Also returned in other circumstances (for example, all calls to API v1 endpoints return 401).
    • 403 Forbidden – The request is understood, but it has been refused or access is not allowed. An accompanying error message will explain why. This code is used when requests are being denied due to update limits . Other reasons for this status being returned are listed alongside the response codes in the table below.
    • 404 Not Found – The URI requested is invalid or the resource requested, such as a user, does not exists. Also returned when the requested format is not supported by the requested method.
    • 406 Not Acceptable – Returned when an invalid format is specified in the request.
    • 410 Gone – This resource is gone. Used to indicate that an API endpoint has been turned off.
    • 420 Enhance Your Calm Returned when an application is being rate limited .
    • 422 Unprocessable Entity – Returned when an image uploaded to POST account / update_profile_banner is unable to be processed.
    • 429 Too Many Requests – Returned when a request cannot be served due to the application’s rate limit having been exhausted for the resource. See Rate Limiting .
    • 500 Internal Server Error = Something is broken. Please post to the developer forums with additional details of your request, in case others are having similar issues.
    • 502 Bad Gateway – Twitter is down or being upgraded.
    • 503 Service Unavailable – The Twitter servers are up, but overloaded with requests. Try again later.
    • 504 Gateway Timeout – The Twitter servers are up, but the request couldn’t be serviced due to some failure within our stack. Try again later.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm returning a list of .NET serialized objects (Project objects) from a JSON web
I`m working on a project where an alert should pop up after returning from
Sending request to action using Ajax, the result type is json. Use a json
I am returning a JSON string from PHP: <?php $results = array( result =>
I want to be able to Ajax-ly retrieve JSON data from some kind of
This project was coped almost exacatly from the example on the admob page but
I have Django project on Dreamhost server which has several views that returns Json
in my project I have a few actions for specifically returning files (pdf/excel) within
Greetings Rails and Javascript Gurus! I have a project where I am returning a
I have the following code returning the error 'object' does not contain a constructor

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.