?在XMLHttpRequest.ResponseText中 [英] ? in XMLHttpRequest.ResponseText

查看:87
本文介绍了?在XMLHttpRequest.ResponseText中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用XMLHttpRequest获取一些HTML文件,并将

ResponseText转储到块元素中;工作正常,除了单个和双个

引号被显示为问号(在
FireFox中的黑色钻石内)


发生了什么事?解决方法是什么?我试过这个:


divElement.innerHTML = x.responseText.replace(/ \?/ g,"''")

>
但它没有任何作用......即使它确实有效也无法区分

来自''


感谢任何帮助...


-E-


I''m fetching some HTML files with XMLHttpRequest and dumping the
ResponseText into block elements; works fine except that single and double
quotes are being displayed as question marks (inside of a black diamond in
FireFox)

What''s going on ? What is the workaround ? I''ve tried this:

divElement.innerHTML = x.responseText.replace(/\?/g, "''")

but it does nothing ... even if it did work it would not be distinguishing "
from ''

Thanks for any help ...

-E-

推荐答案

Elizabeth写道:
Elizabeth wrote:
我正在使用XMLHttpRequest获取一些HTML文件并将
ResponseText转储到块元素中;工作正常,除了单引号和双引号被显示为问号(在FireFox中的黑色钻石内)
I''m fetching some HTML files with XMLHttpRequest and dumping the
ResponseText into block elements; works fine except that single and double
quotes are being displayed as question marks (inside of a black diamond in
FireFox)




听起来像服务器告诉浏览器错误的字符集

在它的响应标题中。


如果你控制服务器(即你,你) ''正在编写

servlet /脚本,在服务器上生成文本),确保

" Content-Type" header具有相应的charset属性。


例如


内容类型:text / html; charset:UTF-8


或其他任何字符集。



It sounds like the server is telling the browser the wrong character set
in it''s response headers.

If you are in control of the server (ie, you''re writing the
servlet/script which produces the text on the server), ensure that the
"Content-Type" header has the appropriate charset attribute.

eg

Content-Type:text/html;charset:UTF-8

or whatever the char set is.




" TheBagbournes" <无*** @ noway.com>在消息中写道

news:dt ********** @ nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com ...

"TheBagbournes" <no***@noway.com> wrote in message
news:dt**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
我正在使用XMLHttpRequest获取一些HTML文件并将
ResponseText转储到块元素中;工作正常,除了单个和
双引号显示为问号(在FireFox中的黑色钻石
内)
I''m fetching some HTML files with XMLHttpRequest and dumping the
ResponseText into block elements; works fine except that single and double quotes are being displayed as question marks (inside of a black diamond in FireFox)



这听起来像服务器在说浏览器错误的字符集
在它的响应标题中。

如果你控制服务器(即你正在编写
servlet / script它在服务器上产生文本),确保
Content-Type header具有相应的charset属性。



It sounds like the server is telling the browser the wrong character set
in it''s response headers.

If you are in control of the server (ie, you''re writing the
servlet/script which produces the text on the server), ensure that the
"Content-Type" header has the appropriate charset attribute.




Content-Type字符集标题是UTF-8 ...它似乎不是

问题;我仍然对它感到困惑。感谢您的回复,如果您有任何其他想法/建议,请告诉我

..


-E-



The Content-Type charset header is UTF-8 ... that doesn''t appear to be the
problem; I''m still baffled by it. Thanks for replying and please let me
know if you have any other ideas/suggestions ..

-E-




Elizabeth写道:

Elizabeth wrote:
Content-Type字符集标题是UTF-8 ...似乎不是
问题;我仍然对它感到困惑。感谢您的回复,请让我知道您是否有任何其他想法/建议..
The Content-Type charset header is UTF-8 ... that doesn''t appear to be the
problem; I''m still baffled by it. Thanks for replying and please let me
know if you have any other ideas/suggestions ..




我的猜测是你正在检索一个页面用排版和排版引用

采用UTF-8嵌入式或微软嵌入式表格。


打开文件并检查文本中的所有引号是否已被转义

正确:& quote;和''


如果你看到任何排版引号(因此左引号不同于

右引号)或某些奇怪的实体,如\& ldquo;或\& rdquo;然后我打赌你找到了原因。

虽然不是JavaScript问题。



My wild guess is that you''re retrieving a page with "typography" quotes
in UTF-8 Embedded or Microsoft Embedded form.

Open the file and check that all quotes in the text are escaped
properly: &quote; and ''

If you see any "typography" quotes (thus left quote differs from the
right one) or some strange entities like \&ldquo; or \&rdquo; then I
bet you''ve found the reason.

Not a JavaScript problem though.


这篇关于?在XMLHttpRequest.ResponseText中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆