【问题标题】:ajax(search suggest) funny character problemajax(搜索建议)有趣的字符问题
【发布时间】:2011-02-02 14:03:28
【问题描述】:

ajax(搜索建议),如果输入有趣的字符(如Ô)并提交,“?”显示在 *****.asp 中。 (response.write(request.form("str")))

我正在使用

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

*****.asp 文件中有<%@CODEPAGE=65001%>

我怎样才能得到正确的单词——*****.asp中的“Ô”

【问题讨论】:

  • 这个问题出在函数 escape() 上。有趣的字符(Ô)被编码

标签: ajax unicode character-encoding asp-classic


【解决方案1】:

escape() 很糟糕,不惜一切代价避免它。试试这个:

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

这会将 Ô 编码为 %C3%94 - 假设它支持 utf8 的页面解码应该没问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-15
    • 1970-01-01
    • 1970-01-01
    • 2013-01-13
    • 1970-01-01
    • 2013-04-08
    • 2013-03-18
    • 1970-01-01
    相关资源
    最近更新 更多