The parameter contains spaces and must be converted to the plus sign when Post is used for submission. In this way, the background program receives the real space, if you are interested, you can find out that the serialize module of jQuery has an r20 regular expression.
The Code is as follows:
Var r20 =/% 20/g,
JQuery. in the param method, all "% 20" is converted to "+", that is, if the data contains spaces before the data is submitted, the space is converted to "% 20" after encodeURIComponent"
The Code is as follows:
EncodeURIComponent ('') ===' % 20'; // true
Finally, you need to convert "% 20" to "=" and then submit the Post. In this way, the background program receives real spaces.
For more information about encodeURIComponent, see MDC description.
EncodeURIComponent escapes all characters should t the following: alphabetic, decimal digits ,-_.! ~ *'()
To avoid unexpected requests to the server, you should call encodeURIComponent on any user-entered parameters that will be passed as part of a URI. for example, a user cocould type "Thyme & time = again" for a variable comment. not using encodeURIComponent on this variable will give comment = Thyme % 20 & time = again. note that the ampersand and the equal sign mark a new key and value pair. so instead of having a POST comment key equal to "Thyme & time = again", you have two POST keys, one equal to "Thyme" and another (time) equal to again.
For application/x-www-form-urlencoded (POST), per http://www.w3.org/TR/html401/interac...m-content-type, spaces are to be replaced by '+ ', so one may wish to follow a encodeURIComponent replacement with an additional replacement of "% 20" with "+ ".
Related:
Https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent
Http://www.w3.org/TR/html401/interact/forms.html#form-content-type