开发者

javascript escape problem with unicode characters

开发者 https://www.devze.com 2023-02-05 20:50 出处:网络
I use the following jquery code to load some date on a specific event from external file: $(\"#container\").load(\"/include/data.php?name=\" + escape(name));

I use the following jquery code to load some date on a specific event from external file:

$("#container").load("/include/data.php?name=" + escape(name));

if the javascript "name" variable contains unicode characters it sends some encoded symbols to data.php file, something like this: %u10E1

开发者_StackOverflowHow can I deal with this encoded symbols? I need to convert them back to readable one.

When I remove the escape function and leave just "name" variable the code doesn't work any more...

Can anyone please help?


If you want to do this manually, then you should be using encodeURIComponent, not escape (which is deprecated)

The jQuery way, however, would be:

$("#container").load("/include/data.php", { "name": name });

Either way PHP should decode it automatically when it populates $_GET.


This may help you.

javascript - how to convert unicode string to ascii

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号