There is such a code that sends data, depending on the visitor, I redirect it to another subdomain.
var http = new XMLHttpRequest();
var url = 'https://example/handler.php';
var params = 'key=' + 'XXX' + "&value=" + 'XXX';
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
document.location.href = http.responseText;
}
}
http.send(params);
Initially there is a page in index.php, but if I need to redirect it to another domain?
It turns out that I am loading index.php, and then another page that returned from the subquery.
How can I block further execution of scripts, html, css, script and wait for the request to be executed from the server, and then either continue further or redirect?
I tried New Promise, did not help
the goal is to redirect the subdomain to another or continue to load the index.php page
document.location.hrefa whole new page loads and the script in current page is gone. Sounds more like a server side issue