Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Ajax
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'); // ist mal wieder wichtig wegen IE
$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 />";
Posted 21-Jan-13 10:20am
Edited 21-Jan-13 10:37am
v2
Comments
Sergey Alexandrovich Kryukov at 21-Jan-13 15:31pm
   
You present no evidence that "code has no mistake"... :-)
—SA
Chi Ller at 21-Jan-13 15:33pm
   
But if the code would have some mistakes, it wouldn´t work by open the request in a new tab, right?
richcb at 21-Jan-13 15:36pm
   
Just because it compiles, does not mean the logic is correct.
Chi Ller at 21-Jan-13 15:38pm
   
so now you have the code. You can convince youself about mistakes
Sergey Alexandrovich Kryukov at 21-Jan-13 15:56pm
   
I cannot see why. This is a pretty usual behavior of wrong code: working in some cases, not in others.
Also, you fail to follow simple logic. What do you call "right" code? If it does not achieve what you wanted to achieve, it is already wrong, in this sense...
—SA
Chi Ller at 21-Jan-13 16:10pm
   
sure in this sense the code is wrong. But when I said there´s no mistake I mean mistakes like a forgotten semikolon, a wrong command,...
Sergey Alexandrovich Kryukov at 21-Jan-13 16:22pm
   
What you are mentioning is next to nothing. We never even discuss the code which does not compile.
OK, you tend to claim things without any arguments at all, so let me break this discussion. You cannot get help by definition, as you simply resist it. To me, case closed. But someone else might find some problem in your code, so -- good luck.
—SA
Sergey Alexandrovich Kryukov at 21-Jan-13 16:28pm
   
Oh no, sorry. That's not all. There is one totally unrelated issue.
 
And this is a big warning for you. I had to remove all your "answers" in this forum, and, by the way, for your own good. Such things often cause reports for abuse. A number of heavier abusers already lost their memberships, but I want just to warn you for now.
 
You "answered" your own questions and then even formally accepted them. Why?! This is cheating. Don't do it; no one will welcome it, if such behavior will be brought to the discussion of the community.
 
Consider you are warned.
 
—SA
Chi Ller at 21-Jan-13 16:39pm
   
Wtf? That´s not cheating. I need help and nowbody could help me. So if I find the solution on my own, I gonna answer my own question and accept the answer. If now somebody else has the same problem he can easy find a working solution.
Sergey Alexandrovich Kryukov at 21-Jan-13 16:46pm
   
I understand that you did not want to do something bad. You can do the following: if you have some interesting solution, you can write a small Tips & Tricks article (or a big one, if appropriate), and post it; you can reference your original question if you want. It won't cause abuse reports. What I say about abuse reports is just the fact...
 
—SA
Zoltán Zörgő at 21-Jan-13 15:46pm
   
Do you have something against jquery? If not, try it. It will care about lots of hings, you would have missed.
Chi Ller at 21-Jan-13 15:51pm
   
I "promised" myself firstly finish all actions by myself before using jquery :D
But I think the code is alright.
Zoltán Zörgő at 21-Jan-13 15:57pm
   
I suggest you try it with jquery. It's a few lines of code only. If you get the same result, than your assumption will be most likely proven. If not, than you missed something. You can also use fiddler to see what's behind.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 235
1 DamithSL 225
2 OriginalGriff 198
3 George Jonsson 170
4 Maciej Los 165
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100