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

179
Views
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
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!