var btn = document.querySelector('button');
btn.addEventListener('click', function() {
  var data = {
    name: "referans",
  };
  xhr.open("POST", url);
  xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
  xhr.onload = function() {
    if(this.status ===200) {
      console.log(this.responseText)
    }
  }
  xhr.send(JSON.stringify(data));
});