67 lines
1.0 KiB
JavaScript
67 lines
1.0 KiB
JavaScript
|
function sleep (time) {
|
||
|
|
||
|
return new Promise((resolve) => setTimeout(resolve, time));
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
function send_web_request($url, $messagestring, $varstring) {
|
||
|
// Browserkompatibles Request-Objekt erzeugen:
|
||
|
r = null;
|
||
|
|
||
|
if(window.XMLHttpRequest)
|
||
|
{
|
||
|
|
||
|
r = new XMLHttpRequest();
|
||
|
}
|
||
|
else if(window.ActiveXObject)
|
||
|
{
|
||
|
|
||
|
try
|
||
|
{
|
||
|
r = new ActiveXObject('Msxml2.XMLHTTP');
|
||
|
}
|
||
|
catch(e1)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
r = new ActiveXObject('Microsoft.XMLHTTP');
|
||
|
}
|
||
|
catch(e2)
|
||
|
{
|
||
|
alert("Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Wenn Request-Objekt vorhanden, dann Anfrage senden:
|
||
|
if(r != null)
|
||
|
{
|
||
|
|
||
|
|
||
|
// HTTP-POST
|
||
|
r.open('POST', $url, true);
|
||
|
|
||
|
r.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
|
|
||
|
r.send($varstring);
|
||
|
if($messagestring != 'no')
|
||
|
{
|
||
|
alert($messagestring);
|
||
|
}
|
||
|
sleep(500).then(() => {
|
||
|
|
||
|
//window.location.href = window.location.href;
|
||
|
//document.location.reload();
|
||
|
|
||
|
});
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
alert("Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.");
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|