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

82
Vistas
How I can output data from request on my SPA using native XMLHttpRequest?

I have a conditional html page and a conditional api.

GET request for user data in my api looks like this:

URL: {host}/user
Method: GET

Headers
- Content-Type: application/json
- Authorization: Bearer {token}

And the response:

Status: 200
Content-Type: application/json
Body:
{
    "first_name": "Ivan",
    "last_name": "Ivanov",
    "phone": "89001234567",
    "document_number": "1224567890"
}

How I can send the requests and output response data using XMLHttpRequest?

I try to use xhr.response() and it's work good, but when I try to xhr.response()['first_name'] it don't work properly

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I see two options given you have native JavaScript and jQuery available

The Fetch API

Or the older "standard" of jQuery.

$.ajax({url: "demo_test.txt", success: function(result){
    $("#div1").html(result);
  }});
about 4 years ago · Juan Pablo Isaza Denunciar

0

The solution was very simple.

Standart output of xhr.response(), where xhr = new XMLHTTPRequest(); not a JSON, so I need to put xhr.responseType = 'json' before xhr.open('POST', url)

about 4 years ago · Juan Pablo Isaza Denunciar
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