Is It OK To Respond With A 400 Bad Request When The Client Does Not Use AJAX?
I'm developing a web app that extensively uses modal dialogs.
The dialogs are loaded via AJAX, and the HTTP response contains just a portion of HTML, not a full HTML document. I don't want a search engine to index these publicly accessible URLs if it finds them.
I can't use a meta robots, as the HTML portion returned does not have a
I prefer to avoid adding every single URL to my
robots.txt, or grouping all my URLs under a common prefix, such as
So I thought I could simply return a 400 Bad Request if the request is not performed with AJAX, i.e. does not contain the
X-Requested-With: XMLHttpRequest header.
400 Bad Request suitable for this purpose?
Verbatim copy of RFC 7231, section 6.5.1:
The 400 (Bad Request) status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error
So yes, it is okay.
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Passing a JS var from AJAX response to Twig
- → when i send data with ajax(jquery) i don't find the values in controller without form in laravel 5.1
- → Uncaught TypeError Illegal invocation when send FormData to ajax
- → Sent Variable to Controller via Ajax in Blade
- → AJAX folder path issue
- → KNockout JS - Automatic reload of ajax call
- → Upload file with iron-ajax (Google Polymer)
- → Drag and Drop(event) not trigger ajax POST
- → Insert values from FORM to DB using AJAX on october cmd
- → 500 Internal Server Error Ajax Laravel
- → Repeating a function using array of values