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

188
Vistas
Where is JSON type post request data located?

When I use Content-Type: application/x-www-form-urlencoded to make a POST request using JavaScript

var url = "http://localhost:80/response.php";
var xhr = new XMLHttpRequest();

xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") // Setting content-type

xhr.onreadystatechange = function() {
    if(xhr.readyState === 4){
        document.getElementById('div_response').innerHTML = xhr.responseText;
    }
};

var data = "message=Hello";
xhr.open("POST", url, true);
xhr.send(data);

POST request data in response.php is located in $_POST variable when Content-Type: application/x-www-form-urlencoded

if(isset($_POST['message']) && !empty($_POST['message'])) {
    echo $_POST['message'];
}

But, when I change the Content-Type to Content-Type: application/json. Where is my posted JSON data located in PHP. Because $_POST doesn't contain any data when Content-Type: application/json.

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