To ensure that JavaScript and ASP, PHP and other back-end programs to transfer value encoding unified _JAVASCRIPT Skills

Source: Internet
Author: User
In the non-English character set of the page, if the use of Ajax methods of data interaction, you must pay attention to ensure that the data before and after the unified coding, otherwise, very easy to appear garbled!
In the case where the backend is an ASP program, it is possible to use the following functions to maintain a unified encoding of the values passed between the front-end JavaScript and the asp:
Encoding: Escape (String)
Decoding: Unescape (String)
Both of these functions exist in both JavaScript and ASP, and are functionally identical, so long as any one end passes data to the other, it is encoded with escape. The end of the receiver with unescape decoding can ensure that JavaScript and ASP data transfer process will not appear garbled!
In the case where the backend is a PHP program, the unified encoding that keeps the values between the front-end JavaScript and PHP can be handled using the following functions:
Web front-end JavaScript
Encoding: encodeURI (String)
Decoding: decodeURI (String)
Web Back-end PHP
Encoding: UrlEncode (String)
Decoding: UrlDecode (String)
Similarly, when the value of the use of the corresponding encoding function encodeURI or UrlEncode, when the use of the corresponding decoding function decodeURI or urldecode, you can ensure that JavaScript and PHP data transfer process will not appear garbled!
In the Web front-end JavaScript decoding, PHP urlencode encoded data, you may need to use two times decoding, such as:
Unescape (decodeURI (String))
Unescape is used to solve some characters that are not character classes, such as punctuation marks, and so on.

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.