Código HTML:
function ajax(strURL,div) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
document.write('Your web browser is not compatible with our system');
return false;
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.setRequestHeader('Accept-Charset', 'iso-8859-1');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage(div, self.xmlHttpReq.responseText);
}
else
{
// updatepage(div,"<div align=\"center\"><img style=\"padding-top:140px;\" src=\"images/loading.gif\" alt=\"Loading\" /></div>");
}
}
self.xmlHttpReq.send("Ajax");
}
function updatepage(div,str){
document.getElementById(div).innerHTML = str;
}
function objetoAjax(){
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 cancelar(){
divFormulario = document.getElementById('formulario');
divFormulario.style.display="none";
divConsulta = document.getElementById('con1');
divConsulta.style.display="none";
}
var pagina="administrar_usuarios.php"
function redireccionar()
{
location.href=pagina
}
function eliminarUsuario(id_usuario){
divResultado = document.getElementById('resultado');
var eliminar = confirm("De verdad desea eliminar este dato?")
if ( eliminar ) {
ajax=objetoAjax();
ajax.open("GET", "eliminar_usuario.php?id_usuario="+id_usuario);
divResultado.innerHTML= '<img src="imagenes/iconos/ajax-loader.gif">';
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
divResultado.innerHTML = ajax.responseText
setTimeout ("redireccionar()", 1);
}
}
ajax.send(null)
}
}

