Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
¿Cómo puedo generar datos de la solicitud en mi SPA usando XMLHttpRequest nativo?

Tengo una página html condicional y una API condicional.

La solicitud GET de datos de usuario en mi API se ve así:

 URL: {host}/user Method: GET Headers - Content-Type: application/json - Authorization: Bearer {token}

Y la respuesta:

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

¿Cómo puedo enviar las solicitudes y generar datos de respuesta usando XMLHttpRequest?

Intento usar xhr.response() y funciona bien, pero cuando intento xhr.response()['first_name'] no funciona correctamente

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Veo dos opciones dado que tiene JavaScript nativo y jQuery disponibles

La API de obtención

O el "estándar" más antiguo de jQuery .

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

0

La solución fue muy sencilla.

Salida estándar de xhr.response() , donde xhr = new XMLHTTPRequest(); no es un JSON, así que necesito poner xhr.responseType = 'json' antes de xhr.open('POST', url)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!