Foros del Web » Programando para Internet » Javascript »

Problema Ajax + Javascript

Estas en el tema de Problema Ajax + Javascript en el foro de Javascript en Foros del Web. Hola a todos, no sé si este es el foro indicado para este tema, pero no he encontrado uno mejor. Les cuento mi problema. Desde ...
  #1 (permalink)  
Antiguo 27/10/2011, 07:48
 
Fecha de Ingreso: julio-2010
Mensajes: 298
Antigüedad: 13 años, 9 meses
Puntos: 8
Problema Ajax + Javascript

Hola a todos, no sé si este es el foro indicado para este tema, pero no he encontrado uno mejor. Les cuento mi problema.
Desde javascript llamo a una función AJAX que me devuelve "True" o "False" dependiendo de la consulta a BBDD
A continuación les dejo el código y luego les cuento el problema:
Código:
function ajaxOnTickTackTrue() {
  alert('true');
}
function ajaxOnTickTackFalse() {
  alert('false');
}
function Tick() {
        clearTimeout(timerID);
        timerID = setTimeout("Tack()", 30000);
        ajaxFunction('http://localhost/services/Tick.ashx?id=1', "", ajaxOnTickTackTrue, ajaxOnTickTackFalse);
}
function Tack() {
        clearTimeout(timerID);
        timerID = setTimeout("Tick()", 30000);
        ajaxFunction('http://localhost/services/Tack.ashx?id=2', "", ajaxOnTickTackTrue, ajaxOnTickTackFalse);
}
function ajaxFunction(url, params, ret_fun_ok, ret_fun_nook)
{
	var xmlHttp = createXMLHttp(); 
	xmlHttp.open("POST", url, true);
	//Send the proper header information along with the request
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
	xmlHttp.onreadystatechange = function ext2(){
		if ( xmlHttp.readyState == 4 ) {
			if ( xmlHttp.status == 200 )
				ret_fun_ok(xmlHttp.responseText);
			else
				ret_fun_nook();
		}
	};
}
function createXMLHttp() 
{
    if (typeof XMLHttpRequest != 'undefined')
	return new XMLHttpRequest();
    else if (window.ActiveXObject) {
	var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp","MSXML2.XmlHttp.3.0", "MSXML2.XmlHttp.4.0","MSXML2.XmlHttp.5.0"];
	for (var i = avers.length -1; i >= 0; i--) {
		try {
		httpObj = new ActiveXObject(avers[i]);
		return httpObj;
		} catch(e) {}
	}
    }
    throw new Error('XMLHttp (AJAX) not supported');
}
El problema es que las llamadas a las páginas Tick.ashx y Tack.ashx siempre devuelven "True", pero me entra a la funcion "ajaxOnTickTackFalse". Alguien sabe el porque? me pueden echar una mano?

Muchas gracias de antemano

Etiquetas: ajax
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:07.