Soy novatin en esto del ajax pero en si funciona... pero mientras realiza la peticion no me muestra el GIF de cargando en Safari y Chrome.. pero si lo hace en IE6 y 9, en Opera y Firefox.
Este es mi script:
Código Javascript
:
Ver originalfunction createREQ() {
try {
req = new XMLHttpRequest(); /* p.e. Firefox */
} catch(err1) {
try {
req = new ActiveXObject('Msxml2.XMLHTTP'); /* algunas versiones IE */
} catch (err2) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP"); /* algunas versiones IE */
} catch (err3) {
req = false;
}
}
}
return req;
}
var http = createREQ();
function agregar(id) {
var miAleatorio = parseInt(Math.random()*99999999);
var url = "Apoyo/agregar.php?id=" + id;
http.open("GET", url + "&rand=" + miAleatorio, true);
http.onreadystatechange = respuestaAjax(id);
http.send(null);
}
function respuestaAjax(id) {
if (http.readyState == 4) {
if (http.status == 200) {
var miTexto = http.responseText;
var brazo = document.getElementById("Producto_ESTADO_" + id);
brazo.innerHTML = miTexto;
} else {
alert("Ha ocurrido un error: " + http.statusText);
}
} else {//cargar animacion mientras se realiza la operacion ajax
document.getElementById("Producto_ESTADO_" + id).innerHTML = "<div id='Producto_OCUPADO'><img src='Apoyo/cargando.gif' width='22' height='22' /></div>";
}
}
¿que puede ser amigos?