Ver Mensaje Individual
  #5 (permalink)  
Antiguo 07/10/2005, 06:12
Saldu
Invitado
 
Mensajes: n/a
Puntos:
A decir verdad hice esto: y no me anda..me gustaría saber porqué... osea.. ustedes que saben,denle una ojeada:
Informante.php:

<?php
session_start();
//require_once('../conexion.php');
$_a=mysql_connect("localhost","root","");
mysql_select_db("Tryman",$_a);
if (!isset($_SESSION["codigoUsuario"]) || $_SESSION["codigoUsuario"] != 'YES') {
$body="no";
}
else
{
$_nick=$_SESSION['codigoUsuario'];
$i = 1;
$query = mysql_query ("SELECT * FROM saldu_mensajes WHERE para=".$_nick." and leido=0");
$_valor=(mysql_num_rows($query)==0)?false:true;
if ($_valor==true) {
$body="si";
mysql_query ("UPDATE saldu_mensajes SET leido=1 WHERE para=".$_nick);
}
else
{
$body="no";
}
}
echo $body;
?>



Bueno...eso sería la parte PHP,pero ahora en ajax hize esto:

INFORMANTE.JS

function objetus()
{
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp
}
function activar_informante()
{
aaa=setInterval("informante();",10000);
}
function informante()
{
_objetus=objetus()
_objetus.open("GET","informante.php",true);
_objetus.onreadystatechange=function() {
if (_objetus.readyState==4)
{
if(_objetus.status==200)
{
if(_objetus.responseText=="si")
{
window.alert("Tienes un mensaje nuevo");
}
}
}
}
_objetus.send(null);
}



Pero a todo esto,yo lo llamo desde una pagina normal,y en esa pagina yo hago:

<script language="JavaScript" src="informante.js"></script>
</head>
<body onload="activar_informante();">

y supuestamente esto tendría que andar..pero no sé porqué razón no funciona... qué estoy haciendo mal? Grax