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

113
Views
Send Json object and receive the response at the same time

For a school project, I am to send JSON. The server processes this file and sends me back a response with a JSON. The whole thing should happen with JavaScript. I have now become aware of the XMLHttpRequest, but don't quite understand it.

Do I have to create two objects with GET and POST or is it possible to combine them?

At the moment I have one var httpPost = new XMLHttpRequest(); to send and one to receive var httpGet = new XMLHttpRequest();

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

let's do it with jQuery AJAX api:

let json = {"key":"val"}
$.post("api.php",json, function(response){
    console.log(response)
});

let's do it with Fetch api:

const data = { username: 'example' };
fetch('api.php', { method: 'POST', body: JSON.stringify(data) })
.then(response => {
  console.log('Success:', response);
}) 
about 4 years ago · Santiago Trujillo 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!