When I used ajax to send a request to the server and carried parameters written in Chinese (GET and POST), I did not use the encoding and decoding functions related to the URL.
But the parameters were still transmitted to the server normally and were processed by the server. The PHP script is recognized normally.
I would like to ask, is the decoding and encoding operation here done automatically by the browser and server?
If it is done automatically, when do you need to manually call the encoding and decoding function?
Well, the main purpose of using UrlEncode is to prevent parameters from being incorrectly parsed as part of the URL. . .
This encoding is not the same thing as the string encoding we often say
Some structures have more than one encoding method, such as arrays:
?a=1&a=2
?a[]=1&a[]=2
, etc. At this time, you may need to manually write it into the one recognized by the server.Some browsers will automatically encode and decode, such as chrome, but not all browsers will do this. Therefore, in most cases, please UrlEncode the passed parameters. I am a .NET backend and will decode once by default.