Hey guys someone knows this problem?
I start an ajax request, but Firebug tells the request is aborted. If you now take a right-click and open the request in a new tab, the request works. So the code has no mistake. But why I don´t recive the answer on the mainpage?
var xmlHttp = false;
if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
<?php
header('Content-Type: text/html; charset=utf-8');
header('Cache-Control: must-revalidate, pre-check=0, no-store, no-cache, max-age=0, post-check=0');
$id = $_POST['id'];
echo $id;
?>
echo "<script>
function loeschen ()
{
var loesche = document.getElementById(".$id.").id;
xmlHttp.open(\"POST\",\"loesch.php\",true);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.send('id='+loesche);
xmlHttp.onreadystatechange = Callback();
}
function Callback ()
{
switch (xmlHttp.readyState)
{
case 4:
if (xmlHttp.status != 200)
{
alert('Fehler');
}
else
{
loesche.innerHTML = xmlHttp.responseText;
}
break;
default:
break;
}
}
</script>";
Here i have the id:
echo "<a style='text-decoration:none; color:white' href='/Inhalte/Kategorien/".$kaufen[6]."' id='$id' önclick='loeschen ()'>".$kaufen[0]."</a><br />";