在ColdFusion中使用<cfcontent type="text/event-stream">,非英语字符显示为问号:???????123123???? ???,但页面的其余部分可以很好地显示非英语字符。
我跟着this tutuorial试着
<cfheader name="Content-Type" value="text/event-stream; charset=utf-8">
而且还
<cfcontent type="text/event-stream; charset=utf-8">
它们都不能在Chrome上工作(不能恢复,开发者工具报告“挂起”,没有重新连接。
发布于 2011-09-08 20:23:39
我试了试下面的代码,运行正常(在Chrome的控制台中显示正确的字符)……
testHTML5ServerSent events
<HTML>
<HEAD>
<script language="javascript">
if (!!window.EventSource) {
var source = new EventSource('sendServerSentEvents.cfm');
source.addEventListener('message', function(e) {
console.log(e.data);
}, false);
source.addEventListener('open', function(e) {
// Connection was opened.
}, false);
source.addEventListener('error', function(e) {
if (e.eventPhase == EventSource.CLOSED) {
// Connection was closed.
}
}, false);
} else {
alert('not supported');// Result to xhr polling :(
}
</script>
</HEAD>
<BODY>
</BODY>
</HTML>sendServerSentEvents.cfm
<cfcontent type="text/event-stream; charset=utf-8" >
data: éêtititiçà
</cfcontent>https://stackoverflow.com/questions/5263192
复制相似问题