title: rails ajax request doesn't work
body: <p>I have some problem with ajax</p>
  
  <p>This request <strong>GET <code>http://localhost:3000/projects/new</code></strong> (304 Not Modified) does work, it executes javascript from response:</p>
  
  <pre><code>$('#add-project-button').hide();
  $('#project-form').append("&lt;form accept-charset=\"UTF-8\" action=\"/projects\" class=\"new_project\" data-remote=\"true\" id=\"new_project\" method=\"post\"&gt;&lt;div style=\"margin:0;padding:0;display:inline\"&gt;&lt;input name=\"utf8\" type=\"hidden\" value=\"&amp;#x2713;\" /&gt;&lt;input name=\"authenticity_token\" type=\"hidden\" value=\"gzu9DETiVV8N+OtRnkdYpD6aa0/RbM7i2H+nkQ0yXGc=\" /&gt;&lt;\/div&gt;\n  &lt;div class=\"field\"&gt;\n    &lt;label for=\"project_name\"&gt;Name&lt;\/label&gt;&lt;br /&gt;\n    &lt;input id=\"project_name\" name=\"project[name]\" size=\"30\" type=\"text\" /&gt;\n  &lt;\/div&gt;\n  &lt;div class=\"actions\"&gt;&lt;input name=\"commit\" type=\"submit\" value=\"Create Project\" /&gt;&lt;\/div&gt;\n&lt;\/form&gt;");
  </code></pre>
  
  <p>But another request <strong>POST <code>http://localhost:3000/projects</code></strong> (200 OK) seems ok but response is empty, no javascript is executing, but the server answer is ok:</p>
  
  <pre><code>Rendered tasks/_task.html.erb (0.0ms)
    Rendered projects/_project.html.erb (4.5ms)
    Rendered shared/_create.js.erb (5.4ms)
    Rendered projects/create.js.erb (6.1ms)
  Completed 200 OK in 96ms (Views: 8.6ms | ActiveRecord: 84.9ms)
  </code></pre>
  
  <p>So I'm guessing that the browser somehow is of not supposed to execute javascript from server in this case. </p>
  
  <p>What might be a problem? How to make browser receive the javascript and execute it? Thanks.</p>
  
  <p>UPDATE: The form which is making ajax request:</p>
  
  <pre><code>&lt;%= form_for(@project, :remote =&gt; true) do |f| %&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :name %&gt;&lt;br /&gt;
      &lt;%= f.text_field :name %&gt;
    &lt;/div&gt;
    &lt;div class="actions"&gt;&lt;%= f.submit %&gt;&lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>The controller action:</p>
  
  <pre><code>def create
    @project = current_user.projects.build(params[:project])
    respond_with(@project.tap(&amp;:save))
  end
  </code></pre>
  
  <p>Maybe the problem is causing by using partial as layout, <strong>projects/create.js.erb</strong>:</p>
  
  <pre><code>&lt;% render :layout =&gt; '/shared/create', locals: { obj: @project } do %&gt;
    $('#project-container').append("&lt;%= escape_javascript render(@project) %&gt;");
    $('#add-project-button').show('fast');
    $('#project-form').hide('fast', function(){ $('#project-form').empty(); });
  &lt;% end %&gt;
  </code></pre>