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

256
Views
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 answers
Answer question

0

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

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!