if (ajax.readyState == 4) { if(ajax.status == 200) { alert(ajax.responseText); } }else{ document.getElementById(mydiv).innerHTML = 'cargando...'; }