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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:54:07+00:00 2026-06-05T14:54:07+00:00

Im trying to send my serialized form data to django where it will should

  • 0

Im trying to send my serialized form data to django where it will should be stored in “mylist” as a list “[video, audio]”. views.py return 0 everytime no matter what boxes I check on my form.

html form

<form id="myform" method="POST">
<input type="checkbox" name="list" value="audio"/> Audio<br />
<input type="checkbox" name="list" value="video"/> Video<br />
<input type="submit" value="Get Custom Library!" /> 
</form>

jquery ajax

<script language="JavaScript">
$(document).ready(function() {
$("#myform").submit(function() {

        $.ajax({
        type: "POST",
        url: 'django/builder/buildit',
        data: $(this).serialize(),
        success: function(response){
            alert(response);
        }
    });
    return false;
});
});
</script>

views.py

from django.http import HttpResponse
def main(request):
  mylist = request.POST.getlist('list')
  message = 0
  for item in mylist:
    if item == 'video':
      message = 'vid'
    elif item == 'audio':
      message = 'aud'
  return HttpResponse(message)
  • 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-05T14:54:08+00:00Added an answer on June 5, 2026 at 2:54 pm

    You’re not giving a key value pair to the data argument, but you shouldn’t even have to go that far – you don’t have to gather the checkbox values yourself. You can replace this:

        var myCheckboxes = new Array();
        $("input:checked").each(function() {
           myCheckboxes.push($(this).val());
        });
    
        $.ajax({
            type: "POST",
            url: 'django/builder/buildit',
            data: myCheckboxes,
            success: function(response){
                alert(response);
            }
        });
    

    With this, using serialize:

        $.ajax({
            type: "POST",
            url: 'django/builder/buildit',
            data: $('#myform').serialize(),
            success: function(response){
                alert(response);
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I`m trying to send simple html page with form data to user with GET,
I'm trying to send a lot of data from a form using the $.post
I am trying to send serialized,compressed data over a tcp connection using protobuf-net and
I am trying to send some serialized data to the view and bind it
I am trying to send an email to customers with html form. here is
i'm trying to send some radio buttons from a form with ajax, the problem
I am trying to send a serialized object using JSON. Here is my view
I am trying to send a serialized Java object from a client to a
I'm trying to use an ajax contact form to send me emails but i'd
I have an applet trying to send java serialized object to a servlet (hosted

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.