title: Rails 5: Respond to AJAX call with HTML (instead of javascript)
body: <p><em>(Rails version 5.1.2)</em></p>
  
  <p>I would like to respond to AJAX with HTML rather than javascript for much the same reasons as outlined in <a href="https://stackoverflow.com/questions/21043068/returning-html-to-ajax-rails-calls">this</a> stack overflow question.</p>
  
  <p>However, I can't actually get it to work.</p>
  
  <p>I'm using <code>form_for</code> with <code>remote: true</code> to send the request via AJAX.  Note that I've also experimented with <code>data: {type: :html}</code>.</p>
  
  <p>My controller action has the line <code>render layout: !request.xhr?</code> and has an associated view.  It's this view that I want sent back to the client.</p>
  
  <p>Yet the client-side code:</p>
  
  <pre><code>$("form").on('ajax:success', (e, data, status, xhr) -&gt;
    console.log xhr.responseText #using console.log data produces same result
  )
  </code></pre>
  
  <p>Gives:</p>
  
  <pre><code>Turbolinks.clearCache()
  Turbolinks.visit("http://localhost:3000/...", {"action":"replace"})
  </code></pre>
  
  <p>Where's the HTML?</p>