1. Change from 400 to 404
I believe that a lot of people have used Ajax technology to get the data, usually using get to get, but the sensitive information can not continue to use get, and then replaced by post, but sometimes when using post, some strange things happen, such as direct access is 400, Plus header and data access is 404, which is confusing, why not from the beginning of the error 404?
Reason for 2.400
400 in the HTTP status code means that the server does not understand your request, this time you should check your request format, because post is the header and body (data) submitted, if you do not have the header then the error is normal, Check the header can be used postman this Google plug-in to check, this plugin can tell you what parameters are missing or is the correct format, the use of the method will not repeat the proposal Baidu. The general header format is as follows
The following is the header of the HTTP format
Reason for 3.404
If you add the head but 404, then do not panic, this time you have requested success, but only data 404 and to, do not see the page is written 404 on the Panic, this time you should pay attention to their body (data) content, read the HTTP should understand, the header is the request header, Body inside is the real data, the data does not look for things, and the format is generally special, you have to consult with the backstage body format problem, is a string or object body, here I give two examples, the following is the object format
This is the data format for the console output:
Here if your background is to accept the format of the string, then you will be error 404, then you should change the format, you should use the object json.stringify the body (data) into a string format,
Here's the data if you can find out the format of it is:
Here is a simple string concatenation, if you have time you can even spell a string of characters and then when the body passes through
This article original, reproduced please indicate the source
Problems with Post methods 400 and 404 in Ajax