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:
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?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'); }
Muchas gracias de antemano