In Ajax, THE post method directly Returns Error Analysis with numbers starting with 0 and starting with ajax0.
Today, I found a strange problem when sending a Verification Code Simulation on the webpage. I use the following code to preset the send verification code button.
This is a Node. js server.
<Pre style = "font-family:; font-size: 9pt; background-color: rgb (255,255,255 ); "> <pre name =" code "class =" javascript "> $ (". reg_code_btn "). click (function (e) {parameters (e.tar get ). parent (). children (). first (). val () $. ajax ({type: "POST", url: "validate/vcode", dataType: "json", data: {vcode: "code"}, success: function (data) {console. log (data); alert (data) ;}, error: function (data) {console. log (data); alert ("error occurred ");}});}); </pre> <br> <pre> </pre> the debugging result is as follows: </pre>
If we only view the part of our code, we will not find any problems. However, if we find that the returned error values of an object have the same commonalities during debugging:
Starting with 0
If I change the return value of the server to the JSON type, the preceding situation disappears.
In summary, when using AJAX to return data, try not to directly return data. JSON data is more secure.
The post method in Ajax described in the above section directly returns an error analysis with a number starting with 0. I hope it will be helpful to you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!