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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:23:46+00:00 2026-06-09T02:23:46+00:00

So I’ve been following this tutorial http://webcloud.se/log/AJAX-in-Django-with-jQuery/ , and the get method works fine.

  • 0

So I’ve been following this tutorial http://webcloud.se/log/AJAX-in-Django-with-jQuery/, and the get method works fine. i.e. I get a popup saying what it should say in the popup. However when I use the post method instead I don’t get anything. It appears that the request doesn’t even reach my view.

This is what my bit of javascript dealing with this looks like:

$(document).ready(function(){

    $("#popupbutton").click(function(){
        $.post("/launch_instances", { 
                name: "Monty",
                food: "Spam" 
            },
            function(data) {
                alert(data);
            }
        );
     });
 ...................

This are the related bit of my template:

<center>
   <div id="popupbutton"><input type="submit" value="Launch Instances!" /></div>
</center>

And here is my views.py:

from django.http import HttpResponse

def li_view(request):
    return HttpResponse("post gets to the view")
    if request.is_ajax():
        if request.method == 'GET':
            message = "This is an XHR GET request"
        elif request.method == 'POST':
            message = "This is an XHR POST request"
        else:
            message = "Nothing"
    else:
        message = "No XHR"

    return HttpResponse(message)

As you can see the first thing I do when I get to my view is return a HttpResponse, but when I am using post I don’t see any popup like I do when I am using get. So my guess is that for some reason the request doesn’t even reach the view.

This is what my urls.py:

from django.conf.urls import patterns, include, url
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^launch_instances/', 'simdata.views.li_view'),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
)

There have been similar questions around but nothing as bizzare as this. I’m new to django/ajax/jquery so probably missing something very small.

Thanks in advance 🙂

  • 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-09T02:23:47+00:00Added an answer on June 9, 2026 at 2:23 am

    Oh! Wow. That is such a small bug, it took me a while of staring at your code to spot it. You’re requesting /launch_instances (notice without the trailing slash at the end). When Django encounters this, it automatically redirects the request to /launch_instances/ (with trailing slash), but through the redirection, the POST data is dropped. Add the trailing slash, and you should be golden.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.