how to send json in js with post

// Sending and receiving data in JSON format using POST method
//
var xhr = new XMLHttpRequest();
var url = "url";
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
    if (xhr.readyState === 4 && xhr.status === 200) {
        var json = JSON.parse(xhr.responseText);
        console.log(json.email + ", " + json.password);
    }
};
var data = JSON.stringify({"email": "[email protected]", "password": "101010"});
xhr.send(data);

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
javascript json post json post javascript send json in post request javascript javascript jsonp post post request javascript json json post request in javascript post javascript json javascript post a json post json with http with javascript how to get json data from post request in javascript send json in request body javascript how to send json data in post send and receive a json object in post request javascript post json data from javascript send json in post request js how to send json object in get request in javascript how to send json object in post request in javascript send a json object post send post request in json js sent json post data send a json post request javascript how to send json data in request js post json data javascript how to send json data with js post json data to api javascript javascript json post request javascript post request json data how to handle application json post request in javascript js http request post json send javascript json send post request with json javascript send json post how to send a json object in post request javascript send post request json js post json request send json body in post request javascript js post json data send json body post request javascript javascript post json request send json object in post request javascript js json post request send json post request javascript post method javascript in json javascript get post json response how to post json data in javascript post request json javascript javascript post request with json body javascript request post json post json js js send post request json post a json object request in javascript post request with json body javascript how to post json string javascipt javascript send json post request javascript post json to api post json from javascript send json post javascript js post json send data in post js post json javascript js send json post js append to request post json js send to request post a json how to receive json object from post method in js javascript send json hoe to post json javascript javascript pass json object with post request javascript send json in http body how to send json body in js javascript send post request with json body javascript method to post json object in html javascript method to post json object json post request example js javascript post json javascript post request example json send json data in post request javascript javascript post request json javascript post request json example js post request json json post request javascript javascript http request post json send json with postrequest in js how to send json in js with post
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source