Guarantee between JavaScript and Asp, Php and other back-end coding unified program pass value (turn)

http://www.jb51.net/article/17801.htm

WEB in the development process, front and rear ends requires consistent data encoding process is often encountered!

On page non-English character sets, if you use Ajax way data exchange, it must be taken to ensure uniform coding data of the front and rear end, otherwise, it is easy to be garbled!
ASP is at the rear end of the program, the unified coding pass retention values between the front and Asp Javascript functions can use the following processes:
encoding: escape (string)
decoding: unescape (string)
these two functions in JavaScript and Asp They are present, but exactly the same function, as long as no end to the other transmitted data are first encoded using Escape, the receiving end can be guaranteed with the decoding unescape Javascript Asp and data transfer process does not occur distortion!
PHP is at the rear end of the program, the unified coding pass retention values between the front end and PHP Javascript may be processed with the following function:
the WEB distal JavaScript
coding: encodeURI (string)
decoding: decodeURI (String)
the WEB rear Php
encoding: urlencode (string)
decoding: urldecode (string)
Similarly, when using the traditional values corresponding coding function urlencode encodeURI or, when using the received corresponding decoding function or decodeURI urldecoded, Javascript, and does not appear to ensure data transfer process Php garbled!
When the front end WEB decoding Javascript, Php in urlencode encoded data , decoding may require the use of two, such as:
unescape (decodeURI (String))
unescape characters used to solve non-text type, such as punctuation marks and the like. 

Reproduced in: https: //www.cnblogs.com/JoannaQ/archive/2012/09/22/2697800.html

Guess you like

Origin blog.csdn.net/weixin_34187822/article/details/93058310