Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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
使用escape_javascript时出现问题:默认javascript_Javascript_Ajax_Ruby On Rails 3 - Fatal编程技术网

使用escape_javascript时出现问题:默认javascript

使用escape_javascript时出现问题:默认javascript,javascript,ajax,ruby-on-rails-3,Javascript,Ajax,Ruby On Rails 3,当我在create操作中遇到这个问题时,我正在做一些ajax功能 在my create.js.erb中: $("follow_form").update('<%= escape_javascript(render("users/unfollow")) %>') $("followers").update('<%= "#{@user.followers.count} followers" %> ') 其中我的部分用户/_unfollow.html.erb: <%=

当我在create操作中遇到这个问题时,我正在做一些ajax功能

在my create.js.erb中:

$("follow_form").update('<%= escape_javascript(render("users/unfollow")) %>') 
$("followers").update('<%= "#{@user.followers.count} followers" %> ')
其中我的部分用户/_unfollow.html.erb:

<%= form_for(current_user.relationships.find_by_followed_id(@user),
            :html => { :method => :delete },
            :remote => true) do |f| %>
<div class='actions'>
    <%= f.submit 'Unfollow' %>
</div>
<% end %>
基本上,单击follow按钮时,follow按钮将变为unfollow。但是,单击按钮时,escape_javascript会返回以下结果:

<form accept-charset=UTF-8 action=/relationships class=new_relationship data-remote=true id=new_relationship method=post>
  <div style=margin:0;padding:0;display:inline>
    <input name=utf8 type=hidden value=&#x2713; />
    <input name=authenticity_token type=hidden value=YwOC5/xVq5FQFJxOiKXR8nGV7/jGMsVEX4OLuWJB56I= />
  div>  
  <div>
    <input id=relationship_followed_id name=relationship[followed_id] type=hidden value=7 />
  div>  
  <div class=actions>    
     <input id=relationship_submit name=commit type=submit value=Follow />  
  div>
form>
您可以看到几乎每个结束标记都缺少“ 然后我开始玩javascript包含。当我改变时,这个ajax功能会起作用

<%= javascript_include_tag :defaults %>

为什么会这样

<%= javascript_include_tag 'prototype' %>