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

247
Views
How to get response to POST request from flask to JavaScript ajax?

I have made a post request from JavaScript to my Flask python code through ajax, but I cannot find a way to return the data in a way that will allow me to get is again through the JavaScript. What I'm trying to do is send data to the Flask server, and return other data back to the JavaScript.

I have tried to use a success: function but it doesn't seem to work and seen as a Uncaught SyntaxError: Unexpected identifier

The relevant part of the JavaScript code:

        $.ajax({
            type: "POST",
            url: "/login",
            data: JSON.stringify(login_info),
            contentType: "application/json",
            dataType: 'json'
            success: function(data){
                console.log(data);
            }
        });

The data im trying to get is the results from the code below V

The Flask(python) code:

@app.route('/login', methods=['POST', 'GET'])
def login():
    if request.method == "POST":
        user_info = request.get_json()
        print(user_info)

        results = {'processed': 'true'}
        return jsonify(results)
    else:
        return render_template("login.html")

about 4 years ago · Juan Pablo Isaza
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!