javascript post request
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="assets/style.css">
<!-- <script src="assets/javascript.js"></script> -->
<title>Telegramga habar jo`natish</title>
</head>
<body>
<div class="contaakb">
<h2>Telegramga habar yozish</h2>
<p>Guruhlarga habar yozish uchun qilingan modul</p>
</div>
<div class="container">
<form action="?" method="post">
<div class="row">
<div class="col-25">
<label for="fname">Guruh nomi</label>
</div>
<div class="col-75">
<input type="text" id="group" name="group" placeholder="Telegram guruhning nomini yozing" value="" autofocus>
</div>
</div>
<div class="row">
<div class="col-25">
<label for="country">Guruh (ixtiyoriy)</label>
</div>
<div class="col-75">
<select id="select" name="select" onchange="getComboA(this)">
<option selected value="tanlang">Tanlang</option>
<option value="ITspeciallessons2">Qobiljon</option>
<option value="ITspeciallessons1">Azizbek</option>
<option value="taxiuchqorgontoshkent">Uchqorgon Toshkent TAXI</option>
<option value="clashuzhackersw">ClashUzHackerSW</option>
<option value="nodirjonbotirov">Nodirjon ISh</option>
</select>
</div>
</div>
<div class="row">
<div class="col-25">
<label for="subject">Habar matni</label>
</div>
<div class="col-75">
<textarea id="message" name="message" placeholder="Habar matnini yozing" style="height:200px" autofocus></textarea>
</div>
</div>
<div class="row">
<button type="submit" onclick="loadDoc(event)">
Jo'natish
</button>
</div>
</form>
</div>
<script type="text/javascript">
function getComboA(selectObject) {
document.getElementById("group").disabled = true;
document.getElementById("message").focus();
console.log('group disabled');
}
function loadDoc(event) {
document.getElementById("message").disabled = true;
document.getElementById("select").disabled = true;
document.getElementById("group").disabled = true;
var params = 'message='+document.getElementById('message').value+'&select='+document.getElementById('select').value+'&group='+document.getElementById('group').value+'&ajax=yes';
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "?", true);
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.responseText;
}
};
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.onreadystatechange = function() {//Call a function when the state changes.
if(xhttp.readyState == 4 && xhttp.status == 200) {
alert(xhttp.responseText);
document.getElementById("message").disabled = false;
document.getElementById("select").disabled = false;
document.getElementById("group").disabled = false;
}
}
xhttp.send(params);
event.preventDefault();
}
</script>
</body>
</html>