Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/07/2008, 07:23
sstealth
 
Fecha de Ingreso: julio-2008
Mensajes: 2
Antigüedad: 15 años, 10 meses
Puntos: 0
Problemas Login

Hola necesito ayuda para que estos dos scritp funcionen como uno ya que al ponerlos juntos tengo problemas no puedo cargar una pag para login ojala alguien pudiese ayudarme graacias de antemano no entiendo mucho de ajax la idea creo k el problema es que ambas crean los mismos objetos

/**** Script para Login****/
function DoCallback(data)
{
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open('POST', url, true);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send(data);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject('Microsoft.XMLHTTP')
if (req) {
req.onreadystatechange = processReqChange;
req.open('POST', url, true);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send(data);
}
}
}

function processReqChange() {
// only if req shows 'loaded'
if (req.readyState == 4) {
// only if 'OK'
if (req.status == 200) {
eval(what);
} else {
alert('There was a problem retrieving the XML data: ' +
req.responseText);
}
}
}


/*****script para cargar pag y llenar BD ****//


function loadurl(url, id){
var pagecnx = createXMLHttpRequest();
pagecnx.onreadystatechange=function()
{
setpage(pagecnx, id)
}
pagecnx.open('GET', url, true)
pagecnx.send(null)
}

function loadurlkey(e,url,id){
tecla = (document.all) ? e.keyCode : e.which;
if (tecla==13)
loadurl(url,id);
}

function setpage(pagecnx, id){
if (pagecnx.readyState == 4 && (pagecnx.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(id).innerHTML=pagecnx.resp onseText;
}

function createXMLHttpRequest() {
var xmlHttp=null;
if (window.ActiveXObject)
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
else
if (window.XMLHttpRequest)
xmlHttp = new XMLHttpRequest();
return xmlHttp;


}
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 enviar(){
//donde se mostrará lo resultados
divResultado = document.getElementById('resultado');
//valores de los inputs
nom=document.productos.nombre.value;
des=document.productos.descrip.value;
stk=document.productos.stock.value;
val=document.productos.valor.value;
cat=document.productos.categ.value;
ajax=objetoAjax();

ajax.open("POST", "Insertar/registro.php",true);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
divResultado.innerHTML = ajax.responseText
LimpiarCampos();
}
}
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
//enviando los valores
ajax.send("nombre="+nom+"&descrip="+des+"&stock="+ stk+"&valor="+val+"&categ="+cat)
}

function LimpiarCampos(){
document.productos.nombre.value="";
document.productos.descrip.value="";
document.productos.stock.value="";
document.productos.valor.value="";
document.productos.categ.value="";
document.productos.nombre.focus();
}
function eliminarDato(id){
divResultado = document.getElementById('resultado');
var eliminar = confirm("De verdad desea eliminar este dato?")
if ( eliminar ) {
ajax=objetoAjax();
ajax.open("GET", "eliminar/eliminacion.php?id="+id);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
divResultado.innerHTML = ajax.responseText
}
}
ajax.send(null)
}
}