Asi ?
Código Javascript
:
Ver originalvar xmlhttp = function() {
var a;
try {
a = new XMLHttpRequest();
} catch (e) {
try {
a = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
a = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {
alert('Your browser doesn\'t support ajax');
a = false;
}
}
}
return a;
};
window.onload = function() {
var a = new comet();
};
var comet = function() {
var a = new xmlhttp();
a.open('post', window.location + "?" + Math.random() + "=" + Math.random(), true);
a.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
a.onreadystatechange = function() {
if (a.readyState == 4) {
var content = document.getElementById('content');
var cambios = true; // alguna condición con el response
if (cambios) {
$(content).fadeOut("slow", function() {
content.innerHTML = a.responseText;
$(content).fadeIn("slow", function() {
window.setTimeout(function() {
a = new comet();
}, 1000);
});
});
} else {
window.setTimeout(function() {
a = new comet();
}, 1000);
}
}
};
a.send('algo=algo');
};