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

154
Vistas
On progress Not working in Ajax Javascript

I have a website that when a user submits the data a function runs and requests a php backend to insert the data into the database but i want to display the spinner on the button when the request has been sent but the on progress function just not working .i have tried everything else please help me.

here is my code of JavaScript

let s_form = document.querySelector("#con-form");

s_form.addEventListener("submit", (e) => {
e.preventDefault();
let name = document.getElementById("name").value;
let email = document.getElementById("email").value;
let mobno = document.getElementById("mobno").value;
let concern = document.getElementById("concern").value;
const xhr_obj = {
name: name,
email: email,
mobno: mobno,
concern: concern,
};
let data_send = JSON.stringify(xhr_obj);
const xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost/dc/utilities/php/h_f_s.php", true);
xhr.setRequestHeader("Content-type", "application/json");
xhr.onprogress = function () {
console.log("appendChild");
 //this is not working why can you find out
};
xhr.onload = function () {
console.log("loaded");
 //this works perfect
};
xhr.send(data_send);
});
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