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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:57:05+00:00 2026-05-27T17:57:05+00:00

I am testing out ajax with Django + jQuery. I have this in my

  • 0

I am testing out ajax with Django + jQuery. I have this in my views:

def ajax_test(request):
    if request.is_ajax():
        message = "This is ajax"
    else:
        message = "Not ajax"
    return HttpResponse(message)

and this in my template:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script type="text/javascript" src="{{ STATIC_URL }}js/jquery-1.6.4.js"></script>
</head>
<body>
<script>
$.get("/ajax_test", function(data) {
    alert(data);
    });
});
</script>
</body>
</html>

My question is – why does this return “Not ajax” to my html page?

  • 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-27T17:57:06+00:00Added an answer on May 27, 2026 at 5:57 pm

    I don’t know what happened to you. I tested and got a good message: This is ajax. My code:

    urls.py

    url(r'^$', 'myapp.views.home', name='home'),
    url(r'^ajax_test/$', 'myapp.views.ajax_test', name='ajax_test'),
    

    views.py

    def home(request):
        return render_to_response('home.html', {},
                              context_instance=RequestContext(request))
    
    def ajax_test(request):
        if request.is_ajax():
            message = "This is ajax"
        else:
            message = "Not ajax"
        return HttpResponse(message)
    

    templates/home.html

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    </head>
    <body>
    <script type="text/javascript">
        $(document).ready(function () {
            $.get("/ajax_test/", function (data) {
                alert(data);
            });
        });
    </script>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm testing out http://code.google.com/p/jquery-loadmask/ where it unmasks after an ajax call: $(#content-container).mask(Waiting...); $.ajax({ url:
I have started to try out noSQL databases now and are currently testing out
I have just started out with testing some php mvc framework In it, it
I am starting out with unit testing, I have a method that uses the
When i submit a jquery ajax request without the data value, it works, when
I have a problem concerning Ajax and Jquery. I have a bunch of <li>
I'm developing a Firefox extension that uses an ajax-request to retrieve information. This is
I have a very simple jQuery/ajax script for a membership driven website. The script
I'm currently testing out retrieving json from jquery. The service url is: http://imgsvc.heroku.com/images In
I'm testing some Jquery Ajax scripts and one of them is actually quite nice.

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.