How to know if xhr send() worked?

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){
  "POST", theUrl, true); // true for asynchronous

          httpGetAsync(window.location, function(response) {
            alert("poll added: " + JSON.stringify(newPoll), response);
            window.location = ""

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.