开发者

ajax(search suggest) funny character problem

开发者 https://www.devze.com 2022-12-25 07:08 出处:网络
ajax(search suggest), if input funny character(like Ô) and submit it, \"?\" is displayed in *****.asp. ( response.write (request.form(\"str\")))

ajax(search suggest), if input funny character(like Ô) and submit it, "?" is displayed in *****.asp. ( response.write (request.form("str")))

i am using

xmlhttp.open("post", "*****.asp", true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send("str="+escape($("str").value));

and there is <%@CODEPAGE=65001%> in *****.asp file

How 开发者_高级运维can i get the correct word--- "Ô" in *****.asp


escape() is terrible, avoid it at all costs. Try this:

xmlhttp.send("str="+encodeURIComponent($("str").value));

This would encode Ô into %C3%94 - assuming the page decoding it supports utf8 you should be fine.

0

精彩评论

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

关注公众号