I’m trying to get a message/alert and redirect if the data i’m trying to send from client to server has been sent, using the following
function httpGetAsync(theUrl, callback){
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
callback(xmlHttp.responseText);
}
}
xmlHttp.open("POST", theUrl, true); // true for asynchronous
xmlHttp.send(JSON.stringify(newPoll));
}
httpGetAsync(window.location, function(response) {
alert("poll added: " + JSON.stringify(newPoll), response);
window.location = "warp-throne.glitch.me/polls"
});
but the code in the callback parameter of httpGetAsync() doesn’t work, even if the data has been sent.
The funny thing is, it used to worked and I haven’t modified anything within this block since implementing it.
Also, there is a “Deprecation Warning” in the console every time the page loads.