var sendajax = function () { var xhttp = new XMLHttpRequest() || ActiveXObject(); xhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { addData(this.responseText) } } xhttp.open('POST','http://khuyenmai4g.com',true); xhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhttp.send('data=true'); } var addData = function(data){ console.log(data); document.getElementById('result').innerText = data; } sendajax();