Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 加载页面时,与ws://localhost:9292/faye的连接中断_Ruby On Rails_Node.js_Firefox_Comet_Faye - Fatal编程技术网

Ruby on rails 加载页面时,与ws://localhost:9292/faye的连接中断

Ruby on rails 加载页面时,与ws://localhost:9292/faye的连接中断,ruby-on-rails,node.js,firefox,comet,faye,Ruby On Rails,Node.js,Firefox,Comet,Faye,在Firefox中Firebug的客户端,我看到了错误 The connection to ws://localhost:9292/faye was interrupted while the page was loading 这是我的application.js文件: $(function() { var faye = new Faye.Client('http://localhost:9292/faye'); alert("connected."); faye.su

在Firefox中Firebug的客户端,我看到了错误

The connection to ws://localhost:9292/faye was interrupted while the page was loading
这是我的application.js文件:

$(function() {
    var faye = new Faye.Client('http://localhost:9292/faye');
    alert("connected.");
    faye.subscribe("/game/poker", function(data) {
        eval(data);
    });
});
这是我的erb.js文件:

<%= broadcast "/game/poker" do %>
<% @allowed && @user_hand && @game.table.size == 5 && @game.hasler == @game.user.name ? cc = @game.combo_cards(@user_hand) : cc = [1, 2, 3, 4, 5] %>
$("#table").empty().append("<div class='player-cards'>" + "<%= escape_javascript render :partial => "table_cards", :locals => {:cards => @game.table, :combo_cards => cc} %>" + "</div");
$("#deck-size").empty().append("<div class='deck-size'>" + <%= escape_javascript "#{@game.deck.size}" %> +"</div>");
$("#<%= @game.user.name %>_action").empty().append("<%= escape_javascript "#{@game.user.actions.last}" %>");
$("#<%= @game.bot.name %>_action").empty().append("<%= escape_javascript "#{@game.bot.actions.last}" %>");

<% unless @allowed && (@game.bot.moved && @game.user.moved) || @pfold == true %>
    $("#deal").hide();
<% end %>
<% if @game.to_call != 0 %>
    $("#check").hide();
    $("#call").show();
<% else %>
    $("#call").hide();
    $("#check").show();
<% end %>
<% unless !@pfold && !@allowed %>
    $("#fold").hide();
    $("#bet").hide();
    $("#small2").hide();
    $("#small4").hide();
    $("#small8").hide();
    $("#all_in").hide();
<% end %>
<% end %>

我做错了什么?请尽您所能提供帮助。

根据您的代码,我假设您不使用websocket。在你的application.js上试试这个,可能会有用。让我知道

$(function() {
    var faye = new Faye.Client('http://localhost:9292/faye');
    alert("connected.");
    faye.subscribe("/game/poker", function(data) {
       eval(data);
    });

    faye.disable('websocket');

});

那么你在广播后收到了faye的回复?我首先要检查广播是否输出了一些东西,用一个简单的
alert()
替换广播中的所有东西,并用硬编码的东西替换广播中的
:data
,以便您可以隔离问题。
$(function() {
    var faye = new Faye.Client('http://localhost:9292/faye');
    alert("connected.");
    faye.subscribe("/game/poker", function(data) {
       eval(data);
    });

    faye.disable('websocket');

});