ajax problem

Kategorien: HTML, JavaScript, CSS, ...
11 Antworten
rompers
rompers am Mittwoch, 25. April 2007 um 14:19
hallo ! schreibe gerade eine script. das soll mit axaj laufen nun ist aber das broblem das wenn ich einen davon
echo '<form method="post" action="javascript:get(document.getElementById(\\'myform\\'));" name="myform" id="myform" style="display:inline">
<div style="display:inline;">
<input style="border:none;background-color:transparent;" type="image" src="images/letters/letter_A.gif" name="qn" id="qn" value="A" onclick="javascript:get(this.parentNode);" />
<input type="hidden" name="qt" id="qt" value="'.$teserre.'" />
<input type="hidden" name="qg" id="qg" value="A" />
<input type="hidden" name="qv" id="qv" value="'.$teserre.'" />
</div>
</form>';
dann klappt es aber habe ich dann noch einen drin das es so aussieht
echo '<form method="post" action="javascript:get(document.getElementById(\\'myform\\'));" name="myform" id="myform" style="display:inline">
<div style="display:inline;">
<input style="border:none;background-color:transparent;" type="image" src="images/letters/letter_A.gif" name="qn" id="qn" value="A" onclick="javascript:get(this.parentNode);" />
<input type="hidden" name="qt" id="qt" value="'.$teserre.'" />
<input type="hidden" name="qg" id="qg" value="A" />
<input type="hidden" name="qv" id="qv" value="'.$teserre.'" />
</div>
</form><form method="post" action="javascript:get(document.getElementById(\\'myform\\'));" name="myform" id="myform" style="display:inline">
<div style="display:inline;">
<input style="border:none;background-color:transparent;" type="image" src="images/letters/letter_B.gif" name="qn" id="qn" value="B" onclick="javascript:get(this.parentNode);" />
<input type="hidden" name="qt" id="qt" value="'.$teserre.'" />
<input type="hidden" name="qg" id="qg" value="B" />
<input type="hidden" name="qv" id="qv" value="'.$teserre.'" />
</div>
</form>';
geht es nicht mehr hier das ganze zusammen
$teserre = time();
if($action == "ajaxpost") {
$teserre = time();
echo '<script type="text/javascript" language="javascript">
   var http_request = false;
   function makePOSTRequest(url, parameters) {
	  http_request = false;
	  if (window.XMLHttpRequest) { // Mozilla, Safari,...
		 http_request = new XMLHttpRequest();
		 if (http_request.overrideMimeType) {
		 	// set type accordingly to anticipated content type
			//http_request.overrideMimeType(\\'text/xml\\');
			http_request.overrideMimeType(\\'text/html\\');
		 }
	  } else if (window.ActiveXObject) { // IE
		 try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
			try {
			   http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		 }
	  }
	  if (!http_request) {
		 alert(\\'Cannot create XMLHTTP instance\\');
		 return false;
	  }
	  
	  http_request.onreadystatechange = alertContents;
	  http_request.open(\\'POST\\', url, true);
	  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	  http_request.setRequestHeader("Content-length", parameters.length);
	  http_request.setRequestHeader("Connection", "close");
	  http_request.send(parameters);
   }
 
   function alertContents() {
	  if (http_request.readyState == 4) {
		 if (http_request.status == 200) {
			//alert(http_request.responseText);
			result = http_request.responseText;
			document.getElementById(\\'myspan\\').innerHTML = result;			
		 } else {
			alert(\\'There was a problem with the request.\\');
		 }
	  }
   }
   
   function get(obj) {
	  var poststr = "qn=" + encodeURI(document.getElementById("qn").value) +
	  							"&qt=" + encodeURI(document.getElementById("qt").value) +
	  							"&qg=" + encodeURI(document.getElementById("qg").value) +
	  							"&qn=" + encodeURI(document.getElementById("qn").value) +
	  							"&qv=" + encodeURI(document.getElementById("qv").value);
	  makePOSTRequest(\\'meinedatei.php?action=ajaxpost\\', poststr);
   }
</script>
 
<form method="post" action="javascript:get(document.getElementById(\\'myform\\'));" name="myform" id="myform" style="display:inline">
<div style="display:inline;">
<input style="border:none;background-color:transparent;" type="image" src="images/letters/letter_A.gif" name="qn" id="qn" value="A" onclick="javascript:get(this.parentNode);" />
<input type="hidden" name="qt" id="qt" value="'.$teserre.'" />
<input type="hidden" name="qg" id="qg" value="A" />
<input type="hidden" name="qv" id="qv" value="'.$teserre.'" />
</div>
</form>
<form method="post" action="javascript:get(document.getElementById(\\'myform\\'));" name="myform" id="myform" style="display:inline">
<div style="display:inline;">
<input style="border:none;background-color:transparent;" type="image" src="images/letters/letter_B.gif" name="qn" id="qn" value="B" onclick="javascript:get(this.parentNode);" />
<input type="hidden" name="qt" id="qt" value="'.$teserre.'" />
<input type="hidden" name="qg" id="qg" value="B" />
<input type="hidden" name="qv" id="qv" value="'.$teserre.'" />
</div>
</form>
<br>
';
if(isset($_POST)) {
echo '<br><br>
Server-Response:<br>
<hr>
<span name="myspan" id="myspan"></span>
<hr>';
 
print_r($_POST);
exit;
}
}
danke für die hilfe mfg rompers ;)