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 6579095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:51:20+00:00 2026-05-25T15:51:20+00:00

I am writing a site, and some pages are requested both with Ajax, or

  • 0

I am writing a site, and some pages are requested both with Ajax, or with a normal request. Of course, when requesting with Ajax, I’d like to render a slightly different template. I’ve tried several methods (A render_block snippet which was a great idea but buggy, using {% include %} to separate the templates while factorizing the code, using {% ifnot request.is_ajax %} to render content, like toolbar or menu, only if not Ajax). So I thought that it would be really cool to do like so :

<div> A menu that should not appear with Ajax </div>
{% ajax %}
<div> The Ajax part </div>
{% endajax %}
<div> A footer that should not appear with Ajax </div>

Then normal request returns :

<div> A menu that should not appear with Ajax </div>
<div> The Ajax part </div>
<div> A footer that should not appear with Ajax </div>

Ajax request :

<div> The Ajax part </div>

However, I don’t really now where to start … I’ve already written template tags, but never had to do something so complicated ! IS it even possible ?

  • 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-25T15:51:20+00:00Added an answer on May 25, 2026 at 3:51 pm

    That sounds like a really confusing way of doing it – I’d definitely stick to:

    {% if not request.is_ajax %}
    <div> A menu that should not appear with Ajax </div>
    {% endif %}
    <div> The Ajax part </div>
    {% if not request.is_ajax %}
    <div> A footer that should not appear with Ajax </div>
    {% endif %}
    

    Alternatively, separate out your templates, so that the stuff you want rendered both times is in one template (we’ll call this my_ajax_template.html):

    <div> The Ajax part </div>
    

    When responding to requests that come from AJAX your view code can just render that template, but when responding to “normal” requests, you could render a template that looked like this:

    <div> A menu that should not appear with Ajax </div>
    {% include 'my_ajax_template.html' %}
    <div> A footer that should not appear with Ajax </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a site where the IndexController holds some pages like about, contact
I’m writing a web site targeted at the iPhone. I’d like to set a
I'm writing an ASP.NET web site targeted at cellphones. The pages appear fine on
i have a PHP web site and i am writing some data to an
So, I'm trying to make cross-site AJAX request from my own script to the
I am currently writing a site that will require a login to use. I
I am writing a site using jquery that repeatedly calls $(window).width() and $(window).height() to
I am writing simple site that requires users and profiles to be handled. The
I'm writing a web site (C#, ASP 3.5) while implementing a simple CMS. In
I am writing a diagnostic site to test our server methods. One of the

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.