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

  • Home
  • SEARCH
  • 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 7874605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:50:20+00:00 2026-06-03T02:50:20+00:00

I recently started to learn jQuery and right now I am playing around with

  • 0

I recently started to learn jQuery and right now I am playing around with .ajax() function.

I cannot figure out how to access the get parameters in Django.

My code looks like:

Jquery & html:

<div id="browser">
    <ul>

    {% comment %}
        Theres a script for each ctg. Each script fades out #astream, fades in #stream_loading and then it should display #astream with new values based on the GET param in ajax call
        Prolly it wont work, but first I need to interact with the GET param in my views.py
    {% endcomment %}

    {% for ctg in ctgs %}
        <script type="text/javascript" charset="utf-8">
            (function($) {
                $(document).ready(function() {
                    $("#stream_loading").hide()

                    $("#browse_{{ctg}}").click(function() {

                        $("#astream").fadeOut()
                        $("#stream_loading").fadeIn()

                        $.ajax({
                            type: "GET",
                            url: "/{{defo}}/?param={{ctg}}",
                            success: function() {
                                $("#stream_loading").fadeOut()

                                $("#astream").fadeIn()
                            }
                        });
                    });
                });
            })(jQuery);
        </script>
        <li><a id="browse_{{ctg}}" title="{{ctg}}">{{ctg}}</a></li>
    {% endfor %}
    </ul>
</div>
<div id="astream">
    {{ajaxGet}} #just to see whats rendered
    {% include "astream.html" %}
</div>

<div id="stream_loading">
    loading stream, please wait ...
</div>

Django:

@https_off
def index(request, template='index.html'):

    request.session.set_test_cookie()

    path=request.META.get('PATH_INFO')
    defo=path[1:path[1:].find('/')+1]
    request.session['defo']=defo
    defo=request.session['defo']

    # build the stream sorted by -pub_date
    import itertools

    chained=itertools.chain(
        model1.objects.order_by('-pub_date').filter(),
        model2.objects.order_by('-pub_date').filter(),
    )

    stream=sorted(chained, key=lambda x: x.pub_date, reverse=True)

    ajaxGet=request.GET.get('param','dummy')

    if request.is_ajax():
        template='astream.html'
        ajaxGet=request.GET.get('param',False)

    renderParams={'defo':defo, 'stream':stream, 'ajaxGet':ajaxGet}

    return render_to_response(template, renderParams, context_instance=RequestContext(request))

Then I try to show it up in my template

{{ ajaxGet }}

But everytime is rendered as ‘dummy’

In firebug I can see get requests with proper key and value.

What do I miss here?

Thanks

  • 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-06-03T02:50:21+00:00Added an answer on June 3, 2026 at 2:50 am

    There is a frequent gotcha that people often fall into when doing this kind of Ajax, and that is not preventing the default action of the link/button. So your Ajax function never has a chance to fire, and the request that you’re seeing in the Django code is caused by the normal page load – which is why is_ajax() is false.

    Give the click handler a parameter, event, and call event.preventDefault(); at the end of the function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm recently started to learn Twisted framework and now looking for some cheat sheets/reference
I recently started C++. I am using PHP right now and decided to take
I have recently started to learn using of Doctrine 2.0 framework for PHP. Now
I recently started to learn how to use openCL to speed up some part
I have recently started to learn Objective-C and write my tests using OCUnit that
I have a friend and he recently started to learn Cinema 4D. He asked
I recently started a new personal project to learn Entity Framework. My end goal
When I started to learn about WPF and MVVM recently, I came across some
I've recently (4 days) started to learn C++ coming from C / Java background.
I've started to learn Ruby recently, and was wondering about which version to learn.

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.