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

185
Vistas
How to convert XMLHttpRequest to json before entering the event?

It is possible to configure the json type information before entering the event, but it does not work for me, and I get errors constantly

function makeRequest6() {
var httpRequest = new XMLHttpRequest();
httpRequest.responseType = 'json'; 

httpRequest.onload = function() 
{
    //var json= JSON.parse(httpRequest.responseText); //i wnat avoid this line
    var json=httpRequest.responseText; // Here it failed
    console.log("Accepted");
    console.log(json);  
    var latestUsd=json.rates.USD; 
    console.log(latestUsd);
};
     
httpRequest.open('GET','http://api.exchangeratesapi.io/v1/latest?access_key=XXXXXXXXXXXXXXXXXXXX');
httpRequest.send();

}

ERROR:

main19.JS:253 Uncaught DOMException: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'json').
at XMLHttpRequest.httpRequest.onload (http://127.0.0.1:5500/lec_19_Ajax_%20getData_JSON/main19.JS:253:30)
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