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

200
Views
XMLHttpRequest does not send parameters with POST request

I am using XMLHttpRequest to make a post request with JavaScript. I make the request and use the send() method with an x-www-form-urlencoded string as the parameter. But when this request gets made in the browser, the paramters I passed through are not sent with the request.
Example: I send a post request

xhttp = new XMLHttpRequest();
xhttp.onload = function() {
    //code
}
xhttp.open('POST', 'https://example.com/request', true);
xhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhttp.send('lorem=ipsum&title=title');

So the request gets sent but instead of being sent like: https://example.com/request?lorem=ipsum&title=title It sends it like this: https://example.com/request with none of the parameters.

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

0

the xhttp.send()'s parameter is the request's body, not request's parameter. So if the backend need parameters, the script does not send any parameters. Move the lorem=ipsum&title=title to xhttp.open('POST', 'https://example.com/request?lorem=ipsum&title=title', true);
Should work

xhttp = new XMLHttpRequest();
xhttp.onload = function() {
    //code
}
xhttp.open('POST', 'https://example.com/request?lorem=ipsum&title=title', true);
xhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhttp.send();
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!