JavaScript - ajax no funciona sobre abierto y cerrado

 
Vista:

ajax no funciona sobre abierto y cerrado

Publicado por santi (2 intervenciones) el 28/07/2013 14:58:45
HOLA pues tengo un sistema de mensajeria el cual me gustaria hacer que el sobre cuando haya un mensaje se abra;tengo un sobre abierto y otro cerrado pero e intentado hacerlo con javacript y ajax y no se que falla:tengo esto;si alguien me puede ayudar y quitar fallos;

hay va el codigo;

index.php:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<script src="ajax.js" language="javascript"></script>
<script>
setTimeout(function cargar (){
$("#destino").load("llamada.php");
},1000);
</script>
<style type="text/css">
#apDiv15 {
position: absolute;
width: 103px;
height: 88px;
z-index: 1;
left: 216px;
top: 20px;
background-color: #666666;
}
</style>
</head>
 
<body>
<div id="apDiv15"><div id="destino".onkeup="Buscar();"><a href='mensajeria.php?id=band'><img src="imagen.php?refrescar" />Mensajería</a></li></div></div>
<div class=""
</body>
</html>

--------------------------
ajax:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function Buscador(){
var xmlhttp=false;
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 Buscar() {
q = document.getElementById('destino').value;
c = document.getElementById('resultados');
ajax = Buscador();
ajax.open("GET","llamada.php?q="+q);
ajax.onreadystatechange = function() {
if (ajax.readyState == 4) {
c.innerHTML = ajax.responseText;
}
}
ajax.send(null)
 
}

----
llamada.php:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
$host = "localhost";
 
$user = "root";
$passw = "";
$db = mensajeria ;
if(!@mysql_connect($host,$user,$passw)) {
print 'se produjo un error al intentar conectar';
}else{
if(!@mysql_select_db($db))
print 'no existe la base de datos';
}
$sql = "SELECT * FROM mensajeria WHERE mensajeria = no";
$rs= mysql_query($sql);
 
$mensajes = mysql_num_rows($rs);
if ($mensajes != 0){
echo "<img src='sobre_abierto.GIF' />";
}else{
echo "<img src='sobre_abierto.GIF'/>";
}
?>


y no va,no da fallos pero las imagenes no se muestran.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.162
Oro
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

ajax no funciona sobre abierto y cerrado

Publicado por xve (2100 intervenciones) el 28/07/2013 21:34:16
Hola Santi, veo algunas cosas un poco extrañas... por ejemplo, utilizas código de jquery ($("#destino").load(".... pero no cargas las librerías de jquery...

En esta linea:
<div id="apDiv15"><div id="destino".onkeup="Buscar();"><a hre... lo que te marco en negrita es erroneo... tendria que ser:
<div id="apDiv15"><div id="destino" onkeyup="Buscar();"><a hre... [/i]

No se si tienes mas errores, pero estos seguro que te aparecen en la consola del navegador... por ejemplo, utilizas Chrome y pulsa la tecla F12... ahi veras la consola con los errores.

Coméntanos, ok?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar