Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/03/2008, 12:58
Avatar de Epunamun
Epunamun
 
Fecha de Ingreso: noviembre-2004
Mensajes: 133
Antigüedad: 19 años, 5 meses
Puntos: 0
Problema con resultado Ajax + Asp

Amigos tengo el siguiente problemilla, con el rut de un cliente deseo saber si se encuentra en la bd, si esta que despliegue los datos y ademas al formulario añada un select y un par de inputs, si no esta que sala un mensaje de error. Lamentablemente no he podido hacer que me muestre los datos.... no se donde esta el error haber si me echan una mano si....


html
Cita:
<form action="#" name="sac01">
<Table width="336" bgcolor="#C0C0C0">
<tr>
<td colspan="3">
<p style="color:#FFFFFF"><b>Ingreso de Operadores S.A.C.</b></p>
</td>
</tr>
<tr>
<td width="80">
<B><FONT face="Tahoma" color="#626262" size="2">RUT:</FONT></B>
</td>
<td width="164">
<INPUT NAME="rut" id='rut' style="background-color:#6699CC;color:#FFFFFF;height:15px" onKeyPress="LP_data()" onKeyUp="validar(this.form)" TYPE="text" maxlength ="8"><FONT face="Tahoma" color="FFFFFF" size="2">-</FONT>
<INPUT TYPE="text" id="dig" NAME="dig" size="1" readonly="True" style=" background-color:#999999;color:#FFFFFF;height:15px" maxlength ="1">
</td>
<td width="76" align="center">
<input type="image" alt="Busca RUT" src="http://www.forosdelweb.com/images/reload.gif" onclick="verificaUsuario();" />
</td>
</tr>
<div id="capaContenedora">
</div>
</Table>
</form>
ajax
Cita:
<script language="javascript" type="text/javascript">
function handleHttpResponse() {
if (http.readyState == 4) {
//carga de Datos
document.getElementById('Layer1').style.display = 'Block';
document.getElementById('Layer2').style.display = 'Block';
alert('cargo');

if (http.status == 200) {
if (http.responseText.indexOf('invalid') == -1) {
// Armamos un array, usando la coma para separar elementos
document.getElementById('Layer1').style.display = 'none';
document.getElementById('Layer2').style.display = 'none';
alert('pasa');
results = http.responseText.split(",");
document.getElementById("datos").innerHTML = results[0] ;
enProceso = false;
}
}
}
}

function verificaUsuario() {
if (!enProceso && http) {
var rut = escape(document.getElementById("rut").value);
var dv = escape(document.getElementById("dig").value);
var url = "operador.asp?rut="+ rut +"&dv="+ dv ;
http.open("GET", url, true);
http.onreadystatechange = handleHttpResponse;
enProceso = true;
http.send(null);
}
}

function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) { xmlhttp = false; }
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) { xmlhttp = false; }
}
return xmlhttp;
}

var enProceso = false; // lo usamos para ver si hay un proceso activo
var http = getHTTPObject(); // Creamos el objeto XMLHttpRequest
asp
Cita:
<%rut = request.QueryString("rut")
dv = request.QueryString("dig")
rut = rut &"-" & dv
sql="SELECT nombrefuncionario, sucursal, d_unidad, mailfuncionario FROM funcionarios WHERE rut_funcionario='" & rut & "'"

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=SQLOLEDB; Data Source = miservidor ; Initial Catalog = mibd; User Id =XXX; Password=XXX;"
set rs = CreateObject("ADODB.Recordset")
rs.Open sql, conn
if not rs.eof
response.write(Rs.fields("NombreFuncionario"))
else
response.Write("<p style='color:##FF0000'>Lo Sentimos Usuario No se encuentra en la Tabla de Funcionarios</p>")
end if
%>

Última edición por Epunamun; 06/03/2008 a las 13:41 Razón: XD no habia cambiado mi servidor.