Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
Pass a string variable from javascript file to a python function

I have an ag-grid. Clicking on its context menu is opening a modal that has a drop-down menu that I want to populate dynamically by fetching the data from a SQLite database.

I want to pass a string variable - network_num from my .js file to a python function. I will then use this variable to execute a query to fetch data from the database. I should then send the fetched data in JSON format to .js file to populate the drop down menu. I am using ajax to send the variable, but it is not working. Please help.

Here is the code

 $.ajax({
                    url: "/get_activity",
                    type: "POST",
                    dataType: "json",
                    data: {
                        network_num: network_num,
                        csrfmiddlewaretoken: '{{ csrf_token }}'
                        },
                    success : function(json) {
                        alert("Successfully sent the variable");
                    },
                    error : function(xhr,errmsg,err) {
                        alert("Could not send URL to Django. Error: " + xhr.status + ": " + xhr.responseText);
                    }
                });
def get_activity(request):
    print("Get activity function is running")
    #I have my sql query here that I want to execute
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Assuming you already have the infrastructure built, in python, request should be passed as a dictionary object, so unless the caller is doing something crazy, it should just be request['network_num']

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!