
error de datos cuando se abre otra pestaña
Publicado por anonymous (2 intervenciones) el 23/06/2014 00:07:35
Veran, tengo un sistema de chat, y cuando abro uno de los tantos inbox que tengo, marcha muy bien. Pero cuando abro otro inbox, es decir, cuando tengo dos pestañas abiertas de chats diferentes: los datos cambian su orden y no se distingue a quien le pertenece cada mensaje.
Les dejo el codigo ajax.
Gracias por su atencion.
Les dejo el codigo 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var obj = null;
function getURL(url, callBackFunc) {
if (window.XMLHttpRequest) {
obj = new XMLHttpRequest();
obj.onreadystatechange = callBackFunc;
obj.open("GET", url, true);
obj.send(null);
} else if (window.ActiveXObject) {
obj = new ActiveXObject("Microsoft.XMLHTTP");
if (obj) {
obj.onreadystatechange = callBackFunc;
obj.open("GET", url, true);
obj.send();
}
}
return obj;
}
function getResponse(obj) {
var data = null;
if ( obj != null ) {
if (obj.readyState == 4) {
if (obj.status == 200) {
data = obj.responseText;
}
}
}
return data;
}
var changeReq = null;
function checkChange() {
changeReq = getURL("comprobar.php?inbox=<?php echo $_GET['inbox']; ?>", takeAction); //la variable inbox esta encriptada
}
function takeAction() {
if ( changeReq ) {
var data = getResponse(changeReq);
if ( data != null && /true/.test(data) ) {
updateContent();
}
}
}
var updateReq = null;
function updateContent() {
updateReq = getURL("nuevos_mensajes.php?inbox=<?php echo $_GET['inbox']; ?>", doUpdate); //la variable inbox esta encriptada
}
var oldata = null;
function doUpdate() {
if ( updateReq ) {
var data = getResponse(updateReq);
if ( data != null ) {
if(data != oldata) {
document.getElementById('inbox2').innerHTML = data;
$("#inbox2").animate({ scrollTop: $('#inbox2')[0].scrollHeight}, 1000);
oldata = data;
}
}
}
}
setInterval("checkChange()", 1000);
Gracias por su atencion.
Valora esta pregunta


0