Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/06/2009, 12:22
Avatar de admado
admado
 
Fecha de Ingreso: junio-2006
Ubicación: Morelos, México
Mensajes: 115
Antigüedad: 18 años
Puntos: 0
Pregunta Problema en paginacion

Con este código puedo hacer la paginación perfectamente, pero necesito pasarlo a AJAX.
Código:
<%
                        Dim mostrar                                                                                        
                        Dim cant_paginas
                        Dim pagina_actual 
                        Dim registro_mostrado 
                        Dim I 
                        
                        mostrar = 10 
                        
                        If Request.QueryString("page") = "" Then
                                               pagina_actual = 1
                        Else
                                               pagina_actual = CInt(Request.QueryString("page"))
                        End If
                        
                        strsql = "SELECT REC_CTA_GASTOS,REC_REFERENCIA FROM TBLA WHERE Rec_status = 'Pendiente' Order by Rec_Cta_Gastos"
 
                        Set RS = Server.CreateObject("ADODB.Recordset")
                        RS.PageSize = mostrar
                        RS.CacheSize = mostrar
 
                        RS.Open strSQL, oCnn,3,1
                        
                        cant_paginas = RS.PageCount
 
                        If pagina_actual > cant_paginas Then pagina_actual = cant_paginas
                        If pagina_actual < 1 Then pagina_actual = 1
 
                        If cant_paginas = 0 Then
                                               Response.Write "No hay registros..."
                        Else
                                               RS.AbsolutePage = pagina_actual
                                               Response.Write "<BR><BR>" & vbCrLf
                                               Response.Write "<TABLE BORDER=""1"">" & vbCrLf
 
                                               ' Mostrando los datos del registro
                                               registro_mostrado = 0
                                               Do While registro_mostrado < mostrar And Not RS.EOF
                                                                       Response.Write vbTab & "<TR>" & vbCrLf
                                                                       For I = 0 To RS.Fields.Count - 1
                                                                       Response.Write vbTab & vbTab & "<TD>"
                                                                       Response.Write RS.Fields(I)
                                                                       Response.Write "</TD>" & vbCrLf
                                               Next 
                                               Response.Write vbTab & "</TR>" & vbCrLf
                                               
                                               registro_mostrado = registro_mostrado + 1
                                               RS.MoveNext
                                               Loop
 
                                               Response.Write "</TABLE>" & vbCrLf
                        End If
 
                        RS.Close
                        Set RS = Nothing
                        oCnn.Close
                        Set oCnn = Nothing
 
                        ' Ahora mostramos los enlaces a las otras páginas con el resto de los registros...
                        If pagina_actual > 1 Then
                        %>
                                               <a href="./paginar2.asp?eje=30&page=<%= pagina_actual - 1 %>"> Anterior</a>
                        <%
                        End If
 
                        ' mostramos la paginacion por numeros de página
                        For I = 1 To cant_paginas
                                               If I = pagina_actual Then
                                               %>
                                               <%= I %>
                                               <%
                                               Else
                                               %>
                                               <a href="./paginar2.asp?eje=30&page=<%= I %>"><%= I %></a>
                                               <%
                                               End If
                        Next 'I
 
                        If pagina_actual < cant_paginas Then
                        %>
                                               <a href="./paginar2.asp?eje=30&page=<%= pagina_actual + 1 %>"> Siguiente</a>
                        <%
                        End If
                        %>
 

Los cambios que le hice al código anterior es esto, para enviarlos a la función

Código:
For I= 1 To cant_paginas
if I= pagina_actual Then
                                             %>
                                             <%= I %>
                                             <%
                      Else
                                             %>
                                             <a href="javascript:cargarPendientes(30,<%= I %>)"><%= I %></a>
                                             <%
                      Ed if 
En AJAX tengo esto, como verán ya lo intente enviando los datos por GET, POST, y no funciona.
Código:
function cargarPendientes(eje,page){
                      //donde se mostrará el resultado
                      divResultado = document.getElementById('pendientes');
                      //instanciamos el objetoAjax
                      ajax=objetoAjax();
//ajax.open("POST", "Pendientes.asp",true);
ajax.open("GET","paginar2.asp?page="+page,true);
//ajax.open("POST", "paginar2.asp?page="&Server.URLEncode(page)&",true);
                      ajax.onreadystatechange=function() {
                                             if (ajax.readyState==1) {
                                                                     divResultado.innerHTML = "<img src='../../../Imagenes/loader.gif' align='center' /><font size=2 color=#FF0000> Cargando . . .</font>";
                                             }else if (ajax.readyState==4){
                                                                     divResultado.innerHTML = ajax.responseText
                                             }
                      }
                      ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                      ajax.send(null)                                     
} 
__________________
>>> El hombre se hace viejo muy pronto y sabio demasiado tarde <<<