JSFiddle - React, Tailwind, and code Playground
HTML
<input type="checkbox" checked="true" id="trabalho" value="Trabalho"> Trabalho </input>
<br/>
<input type="checkbox" id="residencia" value="Residencia">Residencia</input>
<br />
<button onclick="requisicaoAjax()">
Requisicao Ajax
</button>
<div>
<span>Aqui aparecerá o resultado:</span>
<br/>
<span id="conteudo"></span>
</div>
JavaScript
function requisicaoAjax() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
var checkBoxTrabalho = document.getElementById('trabalho');
var checkBoxResidencia = document.getElementById('residencia');
var texto = '';
texto += (trabalho.checked ? 'Trabalho selecionado ' : '');
if (residencia.checked) {
texto += (texto.length? " e " : '');
texto += "Residencia Selecionado";
}
document.getElementById("conteudo").innerHTML = texto;
}
};
xhttp.open("POST", "", true);
xhttp.send();
}