Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.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 链接到远程主机';t工作:使用jrail_Ruby On Rails_Ajax_Jquery_Prototype - Fatal编程技术网

Ruby on rails 链接到远程主机';t工作:使用jrail

Ruby on rails 链接到远程主机';t工作:使用jrail,ruby-on-rails,ajax,jquery,prototype,Ruby On Rails,Ajax,Jquery,Prototype,我正在尝试使用link_to_remote with:with参数,这样我就可以传递我的参数,但我使用的是Jrail,它似乎不起作用。我将它与jrails和prototype一起使用,效果很好。以下是我在jrails中的代码,我不使用prototype: <%= link_to_remote render(:partial => "back_button_text"), {:url => { :controller=> "content", :action =>

我正在尝试使用link_to_remote with:with参数,这样我就可以传递我的参数,但我使用的是Jrail,它似乎不起作用。我将它与jrails和prototype一起使用,效果很好。以下是我在jrails中的代码,我不使用prototype:

<%= link_to_remote render(:partial => "back_button_text"),
   {:url => { :controller=> "content", :action => "ajax_sec_cat_display", :with => "'location=' + $("#history").html()" },
   :loading => "addSpinner()",
   :complete => "removeSpinner()"},
   :class => "menu_item back"
%>
“后退按钮\文本”),
{:url=>{:controller=>“content”,:action=>“ajax_secu_cat_display”,:with=>“'location='+$(“#history”).html()”,
:loading=>“addSpinner()”,
:complete=>“removeSpinner()”},
:class=>“返回菜单项”
%>
下面是正在运行的jrails和原型:

<%= link_to_remote( "Google Map Look Up", 
      :url =>{ :action => :google_map}, 
      :with => "'location=' + $('vcompany_locations_attributes_0_address_1').value") 
   %>
{:action=>:谷歌地图},
:with=>“'location='+$('vcompany\u locations\u attributes\u 0\u address\u 1')。value”)
%>

我终于用非结构化的jquery实现了这一点,如下所示:

$(document).ready(function(){

$(".back").live("click", function() {
    var history = $("#history").html();
    $.ajax({
        beforeSend: function(request){addSpinner();}, 
        complete: function(request){removeSpinner()}, 
        data: 'history=' + history, 
        dataType:'script', 
        type:'post', 
        url:'/content/ajax_back_history'
    });
});
return false;
}))

因此,当您单击它时,它会从history div中获取html并将其发送到rails。我可以在控制器和带有参数[:history]的rjs中使用它

唯一的问题是我没有身份验证令牌,我想知道这是否有什么不好的地方