Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax request returns (406 Not Acceptable )
    primarykey
    data
    text
    <p>In my Rails app javascript template <strong>profile.js.erb</strong> don't get rendered. I get error code <code>406 Not Acceptable</code>. This template is supposed to append a partial in a view <strong>star#profile</strong>. Ajax request is made by jquery infinite scroll plugin. Here is my code</p> <p>. </p> <p><strong>action</strong></p> <pre><code> def profile @page=params[:page] ||1 @videos=Video.all(:page=&gt;@page) respond_to do |format| format.js format.html end end </code></pre> <p><strong>view Stars#profile</strong></p> <pre><code>&lt;div id="content"&gt; &lt;div class="post"&gt; &lt;%=render 'videos'%&gt; &lt;/div&gt; </code></pre> <p><strong>profile.js.erb</strong></p> <pre><code> $('div.post').append("&lt;%=escape_javascript(render 'videos')%&gt;"); </code></pre> <p><strong>routes</strong></p> <pre><code> match "stars/profile/:page"=&gt; "stars#profile", :via =&gt; :get </code></pre> <p><strong>log in console</strong></p> <pre><code>Started GET "/stars/profile?page=2" for 127.0.0.1 at 2013-06-20 00:05:58 -0500 Processing by StarsController#profile as application/JavaScript Parameters: {"page"=&gt;"2"} Completed 406 Not Acceptable in 65836ms </code></pre> <p><strong>Ajax setup</strong> </p> <pre><code> jQuery.ajaxSetup({ 'beforeSend': function(xhr, settings) { xhr.setRequestHeader("Accept", "application/javascript"); var token=$('meta[name="csrf-token"]').attr('content'); xhr.setRequestHeader('X-CSRF-Token',token ); settings['dataType'] = "javascript"; settings['contentType'] = "application/javascript"; } </code></pre> <p>});</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload