Ver Mensaje Individual
  #3 (permalink)  
Antiguo 13/12/2011, 08:58
ocarrasco20
 
Fecha de Ingreso: diciembre-2011
Ubicación: Algarrobo
Mensajes: 17
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: obtener salida html de un asp por ajax

Estimado maycolalvarez soy el mismo usuario de Asembler, gracias por responder, al final lo hizé en asp solo ocupé ajax para no sobrecargar el script, bueno te cuento ahora me pidieron no llamar al css mediante ruta de directorio, sino escanear el css copiarlo todo e insertarlo en el html del informe como podría hacerlo, sería en asp no JS.

Este es mi codigo:


Código ASP:
Ver original
  1. Response.AddHeader "Content-Type", "text/html; charset=iso-8859-1"
  2.  
  3.  
  4.   Dim objXML, strUrl, objHTML, objCSS, strInforme
  5.  
  6.   Const ForReading = 1, ForWriting = 2
  7.  
  8.  
  9.   strUrl = "http://x.x.x.x.x/oscar/alumnos_destacados.asp?IDCOL=10395449"
  10.    
  11.     'Set objXML = Servger.CreateObject ("Microsoft.XMLHTTP")
  12.     Set objXML = Server.CreateObject ("MSXML2.ServerXMLHTTP")
  13.     'Set objXML = Server.CreateObject ("MSXML2.XMLHTTP.3.0")
  14.     'Set objXML = Server.CreateObject ("MSXML2.XMLHTTP.4.0")
  15.  
  16.     If Err then
  17.         Response.write "Error: " & Err.Description
  18.     End if
  19.  
  20.     objXML.Open "GET", strURL, false, "", ""
  21.     objXML.send
  22.  
  23.     If objXML.Status >= 400 And objXML.Status <= 599 Then
  24.         Response.write "Error al obtener página: " & objXML.Status & " - " & objXML.statusText
  25.     Else
  26.         ResponsePage = objXML.ResponseText
  27.     End If
  28.     strLink = "<link href=css/estilos_rep34.css rel=stylesheet type='text/css >"
  29.     ResponsePage = Replace( ResponsePage, "Carga();", "" )
  30.     ResponsePage = ResponsePage & Replace( ResponsePage, strLink, "")
  31.    
  32.     Set fso = CreateObject("Scripting.FileSystemObject")
  33.     Set f = fso.CreateTextFile(Server.Mappath(Request("intCodColegio") & ".html"), False, True)
  34.     Response.AddHeader "Content-Type", "text/html; charset=iso-8859-1"
  35.     f.Write ResponsePage
  36.  
  37.     f.Close
  38.     Set objXML = Nothing
  39.    
  40.     If fso.FileExists(Server.Mappath("css/estilos_rep34.css") ) Then
  41.  
  42.         'Abro el css en modo lectura
  43.         Set objCSS = fso.OpenTextFile( Server.Mappath("css/estilos_rep34.css"), ForReading, True)  
  44.    
  45.         If fso.FileExists( Server.Mappath( Request("intCodColegio") & ".html" ) ) Then
  46.      
  47.             strInforme = Request("intCodColegio") & ".html"
  48.            
  49.            'Abro el INFORME HTML en modo escritura 
  50.             Set objHTML = fso.OpenTextFile( Server.Mappath( strInforme ), 8, True)
  51.  
  52.             'Abro el INFORME HTML en modo escritura
  53.             'Set objHTMLL = fso.OpenTextFile( Server.Mappath( strInforme ), 1) 
  54.            
  55.            
  56.             objHTML.WriteLine("<style type='text/css'>")
  57.                
  58.             If Not objCSS.AtEndOfStream Then
  59.                 objHTML.WriteLine( objCSS.ReadAll() )
  60.             Else
  61.                 objHTML.WriteLine("</style>")      
  62.             End If
  63.          
  64.         End If
  65.    
  66.         objCSS.Close
  67.         objHTML.Close
  68.         set fso = Nothing
  69.  
  70.     End if
  71.  
  72. %>

El tema es el siguiente deseo agregarlo no al final el css sino dentro del header, por favor ayudame con un codigo ejemplificando tal acción

Gracias

P.D: No entiendo porq se me dos veces el informe siendo que leo el css completo y no el informe HTML