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

133
Views
send array from java script to flask

can anyone help me how to return javascript (values) array to flask admin route.we have to just return values,values2,values3 which are java script arrays to flask route named admin .please let if there are any changes in code. we are dynamically taking the values from the user and storing in values,values2,values3 javascript array now we need help to return these array to flask server with route name "/admin"

#flask route
@app.route('/admin',methods = ['POST','GET'])
def admin():
    if request.method == "POST":
        a=request.form.getlist("contacts[]")
        return str(a)
#js code
window.onload = function(){}
var btn = document.querySelector("#btn");
btn.onclick = function(){
    var div= document.createElement("div");
    div.innerHTML = generateit();
    document.getElementById("box").appendChild(div);
}

function generateit()
{
 return "<input type='text' class='txt' placeholder='Enter party name' required>&nbsp<input type='text' class ='txt1' placeholder = 'Enter region' required>&nbsp<input type='text' class='txt2' placeholder='Enter name' required>&nbsp<button id ='btn' onclick='removeit(this);'>Remove</button>";
}

function removeit(btn)
{
    document.getElementById("box").removeChild(btn.parentNode);
}

values =[]
$.ajax({
    url:'{{url_for("admin")}}',
    type:'POST',
    data:{contacts:values},
    success:function(res){}
  });
}
#HTML CODE
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Admin</title>
        <link href="form.css" type="text/css" rel="stylesheet" />
        
    </head>
    <body>
        <form >
        <div id = "box" ><br><br>
        <input type = "text" class="txt" placeholder="Enter party name" required>
        <input type = "text" class="txt1" placeholder="Enter region" required>
        <input type = "text" class="txt2" placeholder="Enter name" required>
        <button id ="btn">ENTER DETAILS</button>
        </div><br><br>
        <div>
            <button class = "sbtn" onclick = "data1(); data2(); data3()" >SUBMIT</button>
        </div>

            
    </form>
    <script type = "text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
        <script type = "text/javascript" src="/static/js/admin.js "></script>
    </body>
</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!