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

Hola amigos,

Yo tengo un codigo javascript que lo tenia funcionando bien en una pagina de testeo, pero cuando lo implemento en el sitio enlinea no me funciona, me di cuenta que cuando quito el doctype del sitio el codigo me funciona bien, pero cuando este esta, me manda un error en lineas que incluso solamente es html.

Este es el Doctype que uso:
Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
Y este es el codigo javascrip que quiero correr:

Código Javascript:
Ver original
  1. function ajaxFunction(){
  2.     var ajaxRequest;  // The variable that makes Ajax possible!
  3.    
  4.     try{
  5.         // Opera 8.0+, Firefox, Safari
  6.         ajaxRequest = new XMLHttpRequest();
  7.     } catch (e){
  8.         // Internet Explorer Browsers
  9.         try{
  10.             ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
  11.         } catch (e) {
  12.             try{
  13.                 ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
  14.             } catch (e){
  15.                 // Something went wrong
  16.                 alert("Your browser broke!");
  17.                 return false;
  18.             }
  19.         }
  20.     }
  21.     // Create a function that will receive data sent from the server
  22.     ajaxRequest.onreadystatechange = function(){
  23.         if(ajaxRequest.readyState == 4){
  24.             var ajaxDisplay = document.getElementById('ajaxDiv');
  25.             ajaxDisplay.innerHTML = ajaxRequest.responseText;
  26.         }
  27.     }
  28.     var comment = document.getElementById('comment').value;
  29.     var idx = document.getElementById('idx').value;
  30.     var usernamex = document.getElementById('usernamex').value;
  31.     var queryString = "?comment=" + comment + "&idx=" + idx + "&usernamex=" + usernamex;
  32.     ajaxRequest.open("GET", "c_action.php" + queryString, true);
  33.     ajaxRequest.send(null);
  34. }


y aqui esta el html con el que funciona:

Código HTML:
<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> 
Les agradeceria alguna ayuda o decirme que doctype puedo utilizar con javascrip.

Saludos de antemano.
AD