开发者

How can i set XMLHttpRequest to support Unicode when it pass data by QueryString?

开发者 https://www.devze.com 2023-03-15 10:45 出处:网络
I use regular XmlHttlRequest, everything work fine except the unicode. How can i set that the query string will support unicode, (right now it return to c# \'??????\' when i pass unicode character (He

I use regular XmlHttlRequest, everything work fine except the unicode. How can i set that the query string will support unicode, (right now it return to c# '??????' when i pass unicode character (Hebrew)). I've tried to set the globalization setting to UTF-16 or Unicode in the web.config like this:

But it still pass '????'.

I attach pic of my code although its a XmlHttpRequest regular code like开发者_JAVA技巧 everyone know.

Thank you!

How can i set XMLHttpRequest to support Unicode when it pass data by QueryString?


XMLHttpRequest won't modify URLs (other than removing invalid characters), you have to build the correct URL yourself. That's what encodeURIComponent function is good for:

xmlRequest.open("GET", "foo.apx?name=" + encodeURIComponent(name));
0

精彩评论

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