In jQuery, while something is loading I can do this:
$.ajax({
url: "/answer_checker.php",
global: false, type: "POST",
data: ({...clipped...}),
cache: false,
beforeSend: function() {
$('#response').html("<img src='/images/loading.gif' />");
},
success: function(html) {
$('#response').html(html);
}
}
How can I apply beforeSend and success in plain javascript? I currently have this:
function processGeneric() {
setTimeout(function () {
if (xmlHttpObject.readyState === 0 || xmlHttpObject.readyState === 4) {
xmlHttpObject.open("GET", requestLink, true);
xmlHttpObject.onreadystatechange = function () {//some code to handle here};
xmlHttpObject.send(null);
}
}, timeout);
}