function BASE(){ if(window.XMLHttpRequest) { try { req = new XMLHttpRequest(); } catch(e) { req = false; } } else if(window.ActiveXObject) { try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { req = false; } } } if(req){ this.HTTP = req; this.error = "" }else{ this.HTTP = null; this.error = "El Navegador no soporta HTTP_REQUEST." } this.result = new Object(); this.commandFile = ""; this.params = ""; } BASE.prototype.send = function(parameter){ if(this.HTTP != null){ this.parameter = parameter == undefined ? this.parameter : parameter; this.parameter = this.parameter + "&commandfile="+this.commandFile; this.HTTP.open("POST", "/clinicamagallanes/componente/database/classNS.php" , false); this.HTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=ISO-8859-1;'); //try { this.HTTP.setRequestHeader("User-Agent","ROCKEROX"); } catch (ex) {} this.HTTP.send(this.parameter); if (this.HTTP.status == 200) { this.result = this.getResult(this.HTTP); }else{ this.result.error = "Error: "+this.HTTP.status +"\n"+ this.HTTP.statusText; } return this.result; }else{ alert(this.error); return null; } } BASE.prototype.sendAsync = function(parameter,functionName){ if(this.HTTP != null){ this.parameter = parameter == undefined ? this.parameter : parameter; this.parameter = this.parameter + "&commandfile="+this.commandFile; this.HTTP.open("POST", "/clinicamagallanes/componente/database/classNS.php" , true); this.HTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=ISO-8859-1;'); //try { this.HTTP.setRequestHeader("User-Agent","ROCKEROX"); } catch (ex) {} this.HTTP.onreadystatechange = functionName; this.HTTP.send(parameter + "&commandfile="+this.commandFile); } } BASE.prototype.getResult = function(Connection){ var result = new Object(); result.numfields = 0; result.numrows = 0; result.error = ""; result.data = null; try{ result.data = Connection.responseXML.documentElement.getElementsByTagName("table")[0]; result.numfields = unescape(result.data.getAttribute("numfields")); result.numrows = unescape(result.data.getAttribute("numrows")); result.error = unescape(result.data.getAttribute("error")); }catch(ex){ result.error = Connection.responseText; } return result; } BASE.prototype.getField = function(_result,_campo,_indice){ try{ if(isNaN(_campo)){ var _value = unescape(_result.data.getElementsByTagName("record")[_indice].getElementsByTagName(_campo)[0].firstChild.nodeValue); }else{ var _value = unescape(RS.data.getElementsByTagName("record")[0].childNodes[_campo].firstChild.nodeValue); } _value = _value.replace('#NULL#','') ; }catch(exception){ alert("Error: No se puede leer el valor de "+_campo); var _value = null; } return _value; } BASE.prototype.getResponse = function(Connection){ var Data = ""; try{ Data = Connection.responseText; }catch(exception){ result.error = "ERROR: No es posible abrir el recordset. \nDescripción:\n"+exception.message; } return Data; }