Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/03/2010, 15:30
Avatar de saymon
saymon
 
Fecha de Ingreso: septiembre-2003
Ubicación: Panama
Mensajes: 318
Antigüedad: 20 años, 8 meses
Puntos: 0
Respuesta: Javascript no me funciona cuando coloco el Doctype.

A pesar de que no soy experto en javascript, si creo que esta alli el problema en alguna incompatibilidad de javascript con el tipo de doctype, porque tambien pense que podria ser algun tipo de conflicto entre el demas codigo, y fui limpiando y limpiando el codigo hasta que quedé solamente con unas cuantas lineas que solo contiene este javascrip y el form del HTML, a continuacion coloco todo el codigo de la pagina: (en donde me funciona bien solamente quitando la primera linea del doctype)


Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	var comment = document.getElementById('comment').value;
	var idx = document.getElementById('idx').value;
	var usernamex = document.getElementById('usernamex').value;
	var queryString = "?comment=" + comment + "&idx=" + idx + "&usernamex=" + usernamex;
	ajaxRequest.open("GET", "c_action.php" + queryString, true);
	ajaxRequest.send(null); 
}

</script>
</head>
<body>

<div id="ajaxDiv">
<form name="myForm">
<textarea name="comment" id="comment" cols="45" rows="5"></textarea><br /><br />
<input type="hidden" name="idx" value="1111" />
<input type="hidden" name="usernamex" value="maria" />
<input type="button" onclick="ajaxFunction()" value="Send Comment" />
</form>
</div>

</body>
</html>