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

97
Vistas
Get rendered template in return from AJAX POST request and refresh the page (not working)

I am trying to send a post request using ajax and refresh my page with the rendered template returned from backend, It refreshes the page but it is not working like it is supposed to, The javascript is broken.

Is there any other way to do this?

Please find the simplified version of the code below:

JAVASCRIPT

$.ajax({
    url: "/post_data",
    type: 'POST',
    contentType: false,
    data: myForm,
    success: function(data){
        console.log("data posted")
        //rendered tempalte returned used to overwrite document
        document.write(data)
    }
    })

PYTHON

app.route("/")
def index(dataName=""):

    if dataName:
        #perform some changes in myTest.html
        print("dataname: ", dataName)
        
    return render_template("myTest.html")    


@app.route('/post_data',methods=["GET","POST"])
def post_data():
    myData = request.form["myDataName"]
    
    #return rendered template returned from index function
    return index(myData)
about 4 years ago · Juan Pablo Isaza
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