In Ajax, THE post method directly Returns Error Analysis with numbers starting with 0 and starting with ajax0.

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.