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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:19:03+00:00 2026-05-26T02:19:03+00:00

Imagine that you need to write some Javascript that simply changes a set of

  • 0

Imagine that you need to write some Javascript that simply changes a set of checkboxes when a drop down list is changed.

Depending on which item is selected in the list, some of the checkboxes will become checked/unchecked.

In the back, you have Python code along with some SQLAlchemy.

The Javascript needs to identify the selected item in the list as usual, send it back to the Python module which will then use the variable in some SQLAlchemy to return a list of checkboxes which need to be checked i.e. “User selected ‘Ford’, so checkboxes ‘Focus’, ‘Mondeo’, ‘Fiesta’ need to be checked”

The issue Im having is that I cant seem to find a way to access the python modules from the Javascript without turning a div into a mini browser page and passing a url containing variables into it!

Does anyone have any ideas on how this should work?

  • 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-26T02:19:03+00:00Added an answer on May 26, 2026 at 2:19 am

    Funny, I’ve got web pages with JavaScript that talk to Python CGI modules that use SQLAlchemy.

    What I do is send AJAX request but with JSON request in the body instead of XML. Python CGI modules use standard json module to deserialize JSON into a dictionary.

    JavaScript side looks like this:

    function on_request_success(response) {
        console.debug('response', response);
    } 
    
    function on_request_error(r, text_status, error_thrown) {
        console.debug('error', text_status + ", " + error_thrown + ":\n" + r.responseText);
    }
    
    var request = { ... };
    jQuery.ajax({
        url: 'http://host/whatever.cgi',
        type: 'POST',
        cache: false,
        data: JSON.stringify(request),
        contentType: 'application/json',
        processData: false,
        success: on_request_success,
        error: on_request_error
    });
    

    And Python like this:

    request = json.load(sys.stdin)
    response = handle_request(request)
    print("Content-Type: application/json", end="\n\n")
    json.dump(response, sys.stdout, indent=2)
    

    Note, it doesn’t use Python cgi module, since the whole request is passed as JSON in the body.

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

Sidebar

Related Questions

I need to create a function in JavaScript, that will write some text (which
Imagine this case where I have an object that I need to check a
I'm trying to write a simple script that will list the contents found in
I need to write a method that loops through ArrayList<String> pathClientStatic and then copies
Imagine that you have a simple site with only 2 pages: login.aspx and secret.aspx.
Imagine that you want to develop a non-trivial end-user desktop (not web) application in
Imagine that I will make an async call in .NET, i.e. HttpWebRequest.BeginGetResponse, and the
Imagine that you have several links on a page. When you clicked, a div
Imagine that during a foreach(var item in enumerable) The enumerable items change. It will
Imagine that I have a nice Deck class, in the best OO fashion. It

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.