if(typeof(EventSource)!=="undefined")
{
var source=new EventSource("/rooms/mess");
source.onmessage=function(event)
{
document.getElementById("result").innerHTML+=event.data + "<br />";
};
}
else
{
document.getElementById("result").innerHTML="Sorry, your browser does not support server-sent events...";
}
这个是我的 JS 主页面
<div class="messages">
<% @messagessang.each do |lin| %>
<p><%= @messagessang.count %></p>
<p><%= lin.content %></p>
<% end %>
</div>
这个是/rooms/mess 的内容 这个文件夹名为 mess.html.erb
后台报错
ActionView::MissingTemplate (Missing template rooms/mess, application/mess with {:locale=>[:"zh-CN"], :formats=>["text/event-stream"], :handlers=>[:erb, :builder, :slim, :coffee, :haml, :jbuilder]}. Searched in:
* "/home/chenglong/luopan_school/app/views"
* "/usr/local/lib/ruby/gems/1.9.1/gems/kaminari-0.16.3/app/views"
):
app/middleware/flash_session_cookie_middleware.rb:16:in `call'