using <cfcontent type="text/event-stream">
in ColdFusion, the non-English characters are displayed as question marks: ???????123123???? ???
, but the rest of the page can display non-English characters just fine.
I followed this tutuorial and tried
<cfheader name="Content-Type" value="text/event-stream; charset=utf-8">
and also
<cfcontent type="text/event-stream; charset=utf-8">
Both of them do not work with Chrome (doesn't pick up, d开发者_开发知识库eveloper tool reported "pending" with no reconnection.
Just tried the following code and it's working fine (showing the correct characters in Chrome's console)...
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>
精彩评论