Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

229
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda