Assuming the link making the request is:
<%= link_to 'New Classroom', new_classroom_path,class: :remote_link, remote: true %>
And that the return processing of it is:
$('.remote_link').bind('ajax:success',function(e, data, status, xhr) {
ajax_replace(data.responseText, status, xhr)
});
function ajax_replace(data, textStatus, request)
{
replace_html(data,request.getResponseHeader("content_id"));
}
In which is the html text returned replaces the html text found in the div that has the same id as the one stored in the "content_id" header
The method that requests the server is:
after_filter :set_featured_id
def new
@classroom = Classroom.new
respond_to do |format|
format.js{render :new, formats: [:html]; head :ok}
end
end
def set_featured_id
response.headers['content_id'] = 'featured'
end
In which a method includes the required value in the header after the execution of the treatment.
The problem is that although the value set in the header is retrieved correctly, the rendered value is not found as responseText.