Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda