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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:43:09+00:00 2026-06-03T01:43:09+00:00

This may be basic, but I’ve spent two days, read countless tutorials and I

  • 0

This may be basic, but I’ve spent two days, read countless tutorials and I still can not get this to work. For simplicitly I tried to accomplish a basic task just to see it work. I want to send make an ajax call to my donate view. I see that it successfully passes through but I was expecting that my template would also get updated to “TRUE” but it remains “FALSE”. Any help or suggestions I appreciate.

my jquery…

$.ajax({
    type: "POST",
    url:"/donate/",
    data: {
    'test': 'success',
    },
    success: function(){
      alert('test')
     },
    error: function(){
        alert("Error");
});

this is my view…

def donate(request):
    if request.is_ajax():
        test = "TRUE"

    if request.method == 'POST':
        form = DonateForm(request.POST)
        if form.is_valid():
            form.save()
    else:
        form = DonateForm()
        test = "FALSE"

    return render_to_response('donate_form.html', {'form':form,'test':test}, context_instance=RequestContext(request))

my template include this…

<h1>{{ test }}</h1>

Update/Solution

Like mentioned in the comments on this question, I was not doing anything the the returned data. I updated my success call to the following and it worked

    $.ajax({
    type: "POST",
    url:"/donate/",
    data: {
    'zip': zip,
    },
    success: function(data){            

        results = $(data).find('#results').html()               
        $("#id_date").replaceWith("<span>" + results + "</span >");

    },
    error: function(){
        alert("Error");
    },
  • 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-03T01:43:10+00:00Added an answer on June 3, 2026 at 1:43 am

    I think the problem is at where you pass the data. Do you use Firebug? An excellent tool for checking if you pass anything in POST, it is an excellent tool for web development in general.

    Here’s a working example for sending Ajax call from a form

    $("#form").submit(function(event) {
            var $form = $(this),
            $inputs = $form.find("input, select, button, textarea"),
            serializedData = $form.serialize();
    
            $.ajax({
                url: "/donate/",
                type: "post",
                data: serializeData,
                success: function(response) {
                    alert(response)
                }
            })
            event.preventDefault();
        });
    

    and then your view can look something like this

    if request.is_ajax() or request.method == 'POST':
            form = DonateForm(data=request.POST)
            if form.is_valid():
                return HttpResponse("Success")
            else:
                return HttpResponse("Fail")
    

    Btw, unless you really need all the extras from $.ajax() I would suggest you to use $.post() instead as it seems more straight forward to use.

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

Sidebar

Related Questions

I'm sorry this may seem a bit basic, but I can't get my head
This may be a basic PHP syntax question, but I could not get any
This may be a basic question but how can I include a module with
This may seem a basic question but my is not currently working. I am
This may be very basic, but I just can`t figure out what to do,
I know this may sound relatively basic question, but still wanted to ask. I
This may be a very basic question. But it is not very clear to
This may be a basic question but why can't I cast a generic type
This may be a basic question but I'm not very proficient in SQL Server.
This may be a basic question, but I could not find an answer for

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.