Request Parameter Losing Plus Sign

本秂侑毒 提交于 2019-11-29 05:40:27

+ means "space" in URLs. Replace it with %2B. You could do this just after composing descriptionsUrlAddition, for example.

descriptionsUrlAddition = descriptionsUrlAddition.replace("+", "%2B");

You should use in the front side The javascript encodeuri function to encode your parameters.

For javascript you should use encodeURIComponent() or encodeuri(). For Example:

var uri = "fj74cvg+fd1==ee";
var res = encodeURIComponent(uri);

and res would be encoded to "fj74cvg%2Bfd1%3D%3Dee"

For php you can use urlencode(). For Example:

<?php
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
?>

These functions will replace any special characters in the string to be used as part of the url.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!