Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3962692
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:07:35+00:00 2026-05-20T03:07:35+00:00

I am wondering how I may jQuery.load an HTML fragment returned by a model’s

  • 0

I am wondering how I may jQuery.load an HTML fragment returned by a model’s show action. For example, $("#container").load("/posts/34"). The problem with this is that it returns the view I want embedded in the layout, as if I were to visit that url in the browser. I only want the Post‘s show HTMl fragment.

Thanks!

Clarification: I want the show view to continue to render within the application layout when going to the show action in my browser. I’m merely trying to figure out how to fetch only the html of the show view for when I want to load it asynchronously with jQuery. I have seen guides in which they create show.js.erb and then render the html view there, but it seems pretty messy to me, escaping all of that html for javascript. If this is the accepted and proper way of doing this though I guess I’ll follow the standard. I was just wondering if it were possible to only fetch the html of a particular view.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:07:35+00:00Added an answer on May 20, 2026 at 3:07 am

    You can use :layout => false in your render statement to return the fragment without the layout:

    def show
      ...
      render(:layout => false) if request.xhr?
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering if the following may be possible using something like jQuery. I've looked
I may want to create a RIA but am wondering, whether Adobe AIR or
This may seem like a daft question, but i was wondering about how to
Wondering why it doesn't load on one click, but on two.................................................................? <input id=btnPaymentAdd type=button
I'm wondering if I may be going about this the wrong way and am
I was wondering what may be the reason to use this median function, instead
I may be way off course, but I was wondering if it's possible to
I'm using the excellent jquery.validation plugin by Jörn Zaefferer and I was wondering whether
Very new to Jquery and wondering if anyone can help me with the following
I have experienced a weird problem with javascript. The problem page uses some jQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.