This URL is a & symbol, the normal Ajax post to PHP will be the & symbol before and after a separate parameter ...
//如:url=http://localhost/app/index.php?c=show&a=index&from=weixin
This is a parameter, the key is the URL, the other is value (not 3 parameters), how can I upload this URL completely to PHP? I heard that you can encrypt this URL in JS, and then decrypt in PHP, but I looked for a bit, JS encryption to quote a lot of things, is there a simple way?
I tried to use the escape character, which was changed to
url=http://localhost/app/index.php?c=show\\&a=index\\&from=weixin
PHP will say that the controller could not be found ...
Reply content:
This URL is a & symbol, the normal Ajax post to PHP will be the & symbol before and after a separate parameter ...
//如:url=http://localhost/app/index.php?c=show&a=index&from=weixin
This is a parameter, the key is the URL, the other is value (not 3 parameters), how can I upload this URL completely to PHP? I heard that you can encrypt this URL in JS, and then decrypt in PHP, but I looked for a bit, JS encryption to quote a lot of things, is there a simple way?
I tried to use the escape character, which was changed to
url=http://localhost/app/index.php?c=show\\&a=index\\&from=weixin
PHP will say that the controller could not be found ...
... Juvenile, the teacher did not teach you querystring parameters must be done UrlEncode =. =
"url="+ encodeURIComponent("http://localhost/app/index.php?c=show&a=index&from=weixin");
PHP back-end should be reasonable $_GET['url'] to get the normal string, if not, please self-urldecode once.
URL encode the parameters and then pass it.
url=encodeURIComponent("http://localhost/app/index.php?c=show&a=index&from=weixin")
Reference: Http://stackoverflow.com/questions/332872/encode-url-in-javascript
Well, just looked at the URL code, using this can solve the problem
str.replace(/(&+)/g,'%26')
It's all right.
And then by the way to see JS has to convert the string to URL encoding method encodeURIComponent() , this should also be possible