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

261
Vistas
Bottle.py | request.forms.get() returning NoneType using AJAX

I am trying to send javaScript information into a bottle.py server using AJAX. After trying nearly every solution I could find on stackOverflow, bottle docs, or Google in general. No solutions have worked.

For clarity sake, I have only included the parts of the code pertaining to the AJAX call. Can anyone explain why request.forms.get is returning None, and how to correct that?

This is the JS code:

let rawData = {"user0Name": users[0],
     "user0Bucks": userBetaBucks[0],
     "user1Name": users[1],
     "user1Bucks": userBetaBucks[1],
     "user2Name": users[2],
     "user2Bucks": userBetaBucks[2],
     "user3Name": users[3],
     "user3Bucks": userBetaBucks[3],
     "user4Name": users[4],
     "user4Bucks": userBetaBucks[4]
    };

$.ajax({
    url: "/updateValues",
    type: "POST",
    dataType: "json",
    data: rawData,
    contentType: "application/json;",
});

This is the python code:

@post('/updateValues')
    def updateValues():
    session = load_session(request)
    gameID = session['gameID']
    rawInfo = json.load(request.forms.get('data'))

Note: 'session = load_session(request)' is a custom function created for retrieving cookies and loading them for later modification within this function. Such as the gameID you see here.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Turns out I needed to be using JSON.stringify() on the data. All is fixed.

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