70 lines
1.1 KiB
JavaScript
70 lines
1.1 KiB
JavaScript
function send_web_request(url, messageString, varString, handleResponse) {
|
|
// 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)
|
|
{
|
|
|
|
|
|
|
|
r.open('POST', url, true);
|
|
|
|
r.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
|
|
if(handleResponse != null) {
|
|
// HTTP-POST
|
|
r.onreadystatechange = function() {
|
|
if (this.readyState == 4 && this.status == 200) {
|
|
handleResponse(this.responseText);
|
|
}
|
|
};
|
|
}
|
|
|
|
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.");
|
|
}
|
|
|
|
|
|
} |