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

181
Vistas
Can someone please tell me why my ajax response is nullifying?

Let's say I have some code similar to this:

let thing = null;
const xhttp = new XMLHttpRequest();
xhttp.onload = function() {
  thing = JSON.parse(this.responseText);
}
xhttp.open("GET", url);
xhttp.send();

console.log(thing.propertyOfThing);

This is not exactly my code, but it works for the purpose of this question. Anyway, the GET request works fine and thing gets set to the JSON object. However, when the code gets to the console.log statement, suddenly thing is null again and I get a NullPointerException (or at least the JavaScript equivalent of that) whenever I try to use properties of the JSON object.

Does anyone know why this is the case?

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