Answers for "xhr javascript post"

0

xhr post

var url = "https://example.com/";

var xhr = new XMLHttpRequest();
xhr.open("POST", url);

xhr.setRequestHeader("Content-Type", "application/json");

xhr.onreadystatechange = function () {
   if (xhr.readyState === 4) {
      console.log(xhr.status);
      console.log(xhr.responseText);
   }};

var data = `{
	"name": "Bob"
}`;

xhr.send(data);
Posted by: Guest on June-11-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language