There is a way to send or get request using ajax which allows to send data without page reload like everything happens behind the scene i found a script for doing that but some of the functions within aer confusing can anyone explain me what are they and why we are using those
data.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
data.onreadystatechange = function () {
if(data.readystate == 4 && data.status == 200) {
data.return_data = data.responseText;
document.getElementById("response").innerHTML = return_data;
}
}
data.setRequestHeader What is the use of this function and why we are using this onreadystatechange same for this and not understanding why if condition is used
Help would be highly appreciated