Foros del Web » Programando para Internet » Javascript »

Error con mi chat

Estas en el tema de Error con mi chat en el foro de Javascript en Foros del Web. Hola yo estoy haciendo un chat y funciona asin tengo un input llamado mensaje y al dalre a enviar el mensaje se guarda en la ...
  #1 (permalink)  
Antiguo 17/08/2012, 04:59
 
Fecha de Ingreso: julio-2012
Mensajes: 276
Antigüedad: 11 años, 8 meses
Puntos: 27
Error con mi chat

Hola yo estoy haciendo un chat y funciona asin

tengo un input llamado mensaje y al dalre a enviar el mensaje se guarda en la base de dato y en un archivo llamado logs tengo el sigueinte codigo y otro que muestra los mensajes guardados.

Código HTML:
Ver original
  1. <script type="text/javascript">
  2. var timer = setInterval("Enviar('logs.php','resultado')", 1);
  3.  
  4.  
  5. function Enviar(_pagina,capa) {
  6. var
  7. ajax;
  8. ajax = ajaxFunction();
  9.  
  10. ajax.open("POST", _pagina, true);
  11.  
  12. ajax.setRequestHeader("Content-Type",
  13. "application/x-www-form-urlencoded");
  14. ajax.onreadystatechange = function()
  15. {
  16.  
  17. if (ajax.readyState == 4)
  18. {
  19. document.getElementById(capa).innerHTML = ajax.responseText;
  20.  
  21. }}
  22. ajax.send(null);
  23. }
  24.  
  25. //Se instancia el objeto y se devuelve
  26. //dependiendo del navegador.
  27. function ajaxFunction() {
  28. var xmlHttp;
  29. try {
  30. // Firefox, Opera 8.0+, Safari
  31. xmlHttp=new XMLHttpRequest();
  32. return xmlHttp;
  33. } catch (e) {
  34. // Internet Explorer
  35. try {
  36. xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  37. return xmlHttp;
  38. } catch (e) {
  39. try {
  40. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  41. return xmlHttp;
  42. } catch (e) {
  43. alert("Tu navegador no soporta AJAX!");
  44. return false;
  45. }}}
  46. }

Y en el index que es donde se manda el mensaje

Yo envio un mensaje y al darle a f5 lo vuelve a enviar y yo no quiero eso.

¿Porque pasa eso?
  #2 (permalink)  
Antiguo 17/08/2012, 17:37
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Error con mi chat

Me parece que el problema poco tiene que ver con PHP, es más bien Javascript/AJAX
__________________
- León, Guanajuato
- GV-Foto

Etiquetas: chat, html
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 17:43.