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

163
Vistas
Send a value in POST request that is inside a **Promise** JavaScript

I have a simple form in html that looks like this:

<form method="post" id="postImageForm" action="storeImage.php">
    <input type="hidden" name="image" id="image-tag">
    <button class="capture-button" type="submit" value="submit"></button>
</form>

and a Javascript eventListner :

PostForm.addEventListener('submit', function(e){
    
    e.preventDefault();
    let imageTag = document.getElementById('image-tag');
    html2canvas(displayScreen).then(canvas=>{
        imageTag.value = canvas.toDataURL();
        appendThumbnail(canvas.toDataURL());
        console.log("inside the promise: "+imageTag.value) //valid results.
    });
    console.log("outside the promise: "+imageTag.value); //empty results.
})

my php file receives empty value and so is my console.log() outside the promise scope.

How can it be fixed to send the value into POST?

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