Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Javascript probblemas con firefox

Estas en el tema de Javascript probblemas con firefox en el foro de Frameworks JS en Foros del Web. hola, bueno estoy haciendo una web y utilizo AJAX para acceder a la BD pongo el codigo: Código: var objXHR_est = false; function enviar_estudios(titulo , ...
  #1 (permalink)  
Antiguo 06/06/2009, 17:13
 
Fecha de Ingreso: abril-2009
Mensajes: 104
Antigüedad: 15 años
Puntos: 0
Sonrisa Javascript probblemas con firefox

hola, bueno estoy haciendo una web y utilizo AJAX para acceder a la BD pongo el codigo:

Código:
  var objXHR_est = false;

function enviar_estudios(titulo , centro , especialidad , fecha_inicio , fecha_final, nivel){

 objXHR_est = creaXHR();
url = "script_estudios.php?titulo=" + titulo + "&centro=" + centro + "&especialidad=" + especialidad + "&fecha_inicio=" + fecha_inicio + "&fecha_final=" + fecha_final + "&nivel=" + nivel;
if(objXHR_est){
  objXHR_est.open("GET", url, true);
  objXHR_est.onreadystatechange = procesar_resposta_enviar_est;
  objXHR_est.send(null);
}else{
  alert("L'objecte XMLHttpRequest no està disponible al seu navegador");
}
}

function procesar_resposta_enviar_est(){
if(objXHR_est.readyState == 4){ 
 text = objXHR_est.responseText;
 respuesta = objXHR_est.responseText;
 var tabla = document.getElementById("est1");
var rows = document.createElement("tr");
rows.innerHTML = respuesta //contiene una cadena con los td
tabla.appendChild(rows);
 
} 
}
el codigo php es este

Código PHP:
$sql "INSERT INTO  movedb.estudios (
id_estudios,
nivel,
titulacion,
centro,
fecha_inicio,
id_candidato,
fecha_final,
cursando,
especialidad
)
VALUES (
NULL ,  '"
.$nivel."',  '".$titulacion."',  '".$centro."',  '".$fecha_inicio."',  '".$_SESSION['id_candidato']."',  '".$fecha_final."',  '".$cursando."',  '".$especialidad."'
);"
;

$_SESSION['i'] = $_SESSION['i'] + 1;
$s mysql_query($sql) or die("Error al intentar seleccionar les dades de l'usuari");
if (
$s == 1){

if ((
$i 2) == 1){
$respuesta '
    <td class="texto_tb3" >'
.$fecha_inicio.' -  '.$fecha_final.'</td>
    <td class="texto_tb3">'
.$titulacion.'</td>
    <td class="texto_tb3">'
.$especialidad.'</td>
    <td class="texto_tb3">'
.$nivel.'</td>
    <td class="texto_tb3">'
.$centro.'</td>
    <td class="text3" align="right"><img src="imagenes/lapiz_01.gif" style="cursor:pointer;" onClick="modificar_exp()">
    </td>
    <td class="text3" align="right"><img src="imagenes/basura_01.gif" style="cursor:pointer;" onClick="eliminar_exp()">
    </td>
'
;

echo 
$respuesta;

}else{


$respuesta '
    <td class="texto_tb2" >'
.$fecha_inicio.' -  '.$fecha_final.'</td>
    <td class="texto_tb2">'
.$titulacion.'</td>
    <td class="texto_tb2">'
.$especialidad.'</td>
    <td class="texto_tb2">'
.$nivel.'</td>
    <td class="texto_tb2">'
.$centro.'</td>
    <td class="text2" align="right"><img src="imagenes/lapiz_01.gif" style="cursor:pointer;" onClick="modificar_exp()">
    </td>
    <td class="text2" align="right"><img src="imagenes/basura_01.gif" style="cursor:pointer;" onClick="eliminar_exp()">
    </td>
'
;

echo 
$respuesta;
}

todo esto esta bien y funciona el problema es que a la hora de escribir la respuesta en firefox todo me sale en un td mientras que en safari funciona correctamente.
gracias de antemano.
  #2 (permalink)  
Antiguo 07/06/2009, 12:27
Avatar de JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 22 años, 2 meses
Puntos: 772
Respuesta: Javascript probblemas con firefox

Mensaje movido al foro de AJAX desde Javascript.

Saludos,
  #3 (permalink)  
Antiguo 07/06/2009, 14:54
 
Fecha de Ingreso: abril-2009
Mensajes: 104
Antigüedad: 15 años
Puntos: 0
Respuesta: Javascript probblemas con firefox

porfavor necesito una respuesta, gracias
  #4 (permalink)  
Antiguo 08/06/2009, 11:10
 
Fecha de Ingreso: julio-2008
Ubicación: Alcañiz-Teruel-España
Mensajes: 182
Antigüedad: 15 años, 9 meses
Puntos: 5
Respuesta: Javascript probblemas con firefox

Pruebate esta prueba que te he echo, aver si te convence...

index.php
Código html:
Ver original
  1. .texto_tb3{
  2. color:red;
  3. }
  4. .texto_tb2{
  5. color:blue;
  6. }
  7.  
  8.  
  9. function creaXHR(){
  10.    var xmlhttp=false;
  11.    try {
  12.        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  13.    } catch (e) {
  14.        try {
  15.           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  16.        } catch (E) {
  17.            xmlhttp = false;
  18.        }
  19.    }
  20.    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  21.       xmlhttp = new XMLHttpRequest();
  22.    }
  23.    return xmlhttp;
  24. }
  25.  
  26. function enviar_estudios(titulo , centro , especialidad , fecha_inicio , fecha_final, nivel, n){
  27.  
  28.   objXHR_est = creaXHR();
  29.   url = "p.php?titulacion=" + titulo + "&centro=" + centro + "&especialidad=" + especialidad + "&fecha_inicio=" + fecha_inicio + "&fecha_final=" + fecha_final + "&nivel=" + nivel;
  30.   if(objXHR_est){
  31.     objXHR_est.open("GET", url, true);
  32.     objXHR_est.onreadystatechange = function () {
  33.       if(objXHR_est.readyState == 4){
  34.         alert(objXHR_est.responseText)
  35.         var tabla = document.getElementById("est1");
  36.         var i = parseInt(document.getElementById("i").value);
  37.         document.getElementById("i").value = i+1;
  38.         var col1 = document.createElement("td");
  39.         var col2 = document.createElement("td");
  40.         var col3 = document.createElement("td");
  41.         var col4 = document.createElement("td");
  42.         var col5 = document.createElement("td");
  43.         var col6 = document.createElement("td");
  44.         var col7 = document.createElement("td");
  45.         col1.innerHTML = fecha_inicio +"-"+ fecha_final
  46.         col2.innerHTML = titulo
  47.         col3.innerHTML = especialidad
  48.         col4.innerHTML = nivel
  49.         col5.innerHTML = centro
  50.         col6.innerHTML = '<img src="imagenes/lapiz_01.gif" style="cursor:pointer;" onClick="modificar_exp()">'
  51.         col7.innerHTML = '<img src="imagenes/basura_01.gif" style="cursor:pointer;" onClick="eliminar_exp()">'
  52.         if (i%2==1) {
  53.           col1.className='texto_tb3'
  54.           col2.className='texto_tb3'
  55.           col3.className='texto_tb3'
  56.           col4.className='texto_tb3'
  57.           col5.className='texto_tb3'
  58.           col6.className='texto_tb3'
  59.           col7.className='texto_tb3'
  60.         }else{            
  61.           col1.className='texto_tb2'
  62.           col2.className='texto_tb2'
  63.           col3.className='texto_tb2'
  64.           col4.className='texto_tb2'
  65.           col5.className='texto_tb2'
  66.           col6.className='texto_tb2'
  67.           col7.className='texto_tb2'
  68.         }
  69.         var row = document.createElement("tr");
  70.         row.appendChild(col1); // agrega la columna al renglon
  71.         row.appendChild(col2); // agrega la columna al renglon
  72.         row.appendChild(col3); // agrega la columna al renglon
  73.         row.appendChild(col4); // agrega la columna al renglon
  74.         row.appendChild(col5); // agrega la columna al renglon
  75.         row.appendChild(col6); // agrega la columna al renglon
  76.         row.appendChild(col7); // agrega la columna al renglon
  77.  
  78.         //row.innerHTML = respuesta //contiene una cadena con los td
  79.         tabla.appendChild(row);
  80.       }
  81.     }
  82.     objXHR_est.send(null);
  83.   }else{
  84.     alert("L'objecte XMLHttpRequest no està disponible al seu navegador");
  85.   }
  86. }
  87.  
  88.  
  89.  
  90. <input type="button" value="Add" onclick="enviar_estudios('titulo' , 'centro' , 'especialidad' , 'fecha_inicio' , 'fecha_final', 'nivel')"/>
  91. <input type="hidden" id="i" value='1'"/>
  92. <tbody id="est1">
  93. <tr>
  94.     <th>Fecha</th>
  95.     <th>Titulacion</th>
  96.     <th>Especialidad</th>
  97.     <th>Nivel</th>
  98.     <th>Centro</th>
  99.     <th></th>
  100.     <th></th>
  101. </tr>

p.php
Código php:
Ver original
  1. <?PHP
  2. header('Content-Type: text/xml; charset=ISO-8859-1');
  3. //session_start();
  4. $fecha_inicio=$_GET['fecha_inicio'];      
  5. $fecha_final=$_GET['fecha_final'];      
  6. $titulacion  =$_GET['titulacion'];      
  7. $especialidad=$_GET['especialidad'];    
  8. $nivel       =$_GET['nivel'];        
  9. $centro      =$_GET['centro'];
  10.        
  11. $sql = "INSERT INTO  movedb.estudios (
  12. id_estudios,
  13. nivel,
  14. titulacion,
  15. centro,
  16. fecha_inicio,
  17. id_candidato,
  18. fecha_final,
  19. cursando,
  20. especialidad
  21. )
  22. VALUES (
  23. NULL ,  '".$nivel."',  '".$titulacion."',  '".$centro."',  '".$fecha_inicio."',  '".$_SESSION['id_candidato']."',  '".$fecha_final."',  '".$cursando."',  '".$especialidad."'
  24. );";
  25. //$i=$_SESSION['i'];
  26. //$_SESSION['i'] = $_SESSION['i'] + 1;
  27. $s = mysql_query($sql) or die("Error al intentar seleccionar les dades de l'usuari");
  28. echo "SQL INSERT OK: $sql";  
  29. //if ($s == 1){
  30.  
  31. //if (($i % 2) == 1){
  32. //$respuesta = '
  33. //    <td style="background-color=\'LemonChiffon\'">'.$fecha_inicio.$i.' -  '.$fecha_final.$i.'</td>|
  34. //    <td style="background-color=\'LemonChiffon\'">'.$titulacion.$i.'</td>|
  35. //    <td style="background-color=\'LemonChiffon\'">'.$especialidad.$i.'</td>|
  36. //    <td style="background-color=\'LemonChiffon\'">'.$nivel.$i.'</td>|
  37. //    <td style="background-color=\'LemonChiffon\'">'.$centro.$i.'</td>
  38. //';
  39.  
  40. //echo $respuesta;
  41.  
  42. //}else{
  43.  
  44.  
  45. //$respuesta = '
  46. //    <td style="background-color=\'Khaki\'">'.$fecha_inicio.$i.' -  '.$fecha_final.$i.'</td>
  47. //    <td style="background-color=\'Khaki\'">'.$titulacion.$i.'</td>
  48. //    <td style="background-color=\'Khaki\'">'.$especialidad.$i.'</td>
  49. //    <td style="background-color=\'Khaki\'">'.$nivel.$i.'</td>
  50. //    <td style="background-color=\'Khaki\'">'.$centro.$i.'</td>
  51. //';
  52.  
  53. //echo $respuesta;
  54. //}
  55. //}  
  56. ?>

Ya me dices

Saludos,...
__________________
Si quieres puedes y si puedes debes. Imposible is nothing!!!
  #5 (permalink)  
Antiguo 11/06/2009, 10:17
 
Fecha de Ingreso: abril-2009
Mensajes: 104
Antigüedad: 15 años
Puntos: 0
Respuesta: Javascript probblemas con firefox

ok, gracias lo probare y te digo algo
  #6 (permalink)  
Antiguo 11/06/2009, 10:29
 
Fecha de Ingreso: abril-2009
Mensajes: 104
Antigüedad: 15 años
Puntos: 0
Respuesta: Javascript probblemas con firefox

gracias lo he mirado y si mefunciona, muchas gracias
  #7 (permalink)  
Antiguo 11/06/2009, 12:40
 
Fecha de Ingreso: abril-2009
Mensajes: 104
Antigüedad: 15 años
Puntos: 0
Respuesta: Javascript probblemas con firefox

Bueno, escribo para darte las gracias (matak) por ayudarme me hiciste un gran favor , muchas gracias
  #8 (permalink)  
Antiguo 12/06/2009, 01:22
 
Fecha de Ingreso: julio-2008
Ubicación: Alcañiz-Teruel-España
Mensajes: 182
Antigüedad: 15 años, 9 meses
Puntos: 5
Respuesta: Javascript probblemas con firefox

Nada hombre pa eso estamos

Saludos,
__________________
Si quieres puedes y si puedes debes. Imposible is nothing!!!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:49.