capture data from ASP to javascript

0

I have a doubt I want to capture data from start dates and end of an ASP query to jQuery, this data is sent to an email, but it shows me the data in white.

 <%

dim i, Q
dim fInicio, fTermino
dim lCentros

' obtener fechas anteriores
fInicio  = DateAdd("d", -7, now())
fTermino = DateAdd("d", 6, fInicio)



' Listar centros notificados
  Q = "SELECT werks,"&_
 "      stort "&_
 "FROM dbo.SAP_ControlMineria_Notificacion "&_
 "WHERE id_usuario <> 'job' "&_
 "  AND fNotificacion BETWEEN '"& fInicio &"' AND '"& fTermino &"' "&_
 "GROUP BY werks, stort "&_
 "ORDER BY werks, stort;"



 lCentros = getDBP(Q)

%>


 <!-- fila -->
 <div class="row-fluid">
  ENVIO DE CORREO SEMANAL, REP 3


 </div>
  <div class="clearfix"></div>

 <script>

$(document).ready(function() {
// Se enviara correo de notif. a Mantenimiento
var fecini  = $("#<%=fInicio%>").val();
var fecfin  = $("#<%=fTermino%>").val();
var werks   = 'M027';         
var stort   = 'SALVADORC2';           
var func    = 'normal';
var fechaNotif = $("#<%=fTermino%>").val();
 $.ajax({
    async:false,    
    cache:false,   
    dataType:"html",
    type: 'POST',   
    url: "rep3_notificacion.asp",
    data: {
            fecini:fecini
          , fecfin:fecfin  
          , werks:werks       
          , stort:stort       
          , func:func           
    }, 
    success:  function(respuesta){  
        $("#mostrarRep").html(respuesta);

        // enviar correo reporte mantenmiento
        $.post("rep3_notificacion_email.asp", { werks:werks , stort:stort , tablas:respuesta, fechaNotif:fechaNotif }, function(data) {
        }).done(function() {
            // enviar mensaje de ejecucion correcta
            window.location.href = "rep7_detalle.asp";
        }).fail(function() {
            window.location.href = "rep8_detalle.asp";
        });

    },
    beforeSend:function(){},
    error:function(objXMLHttpRequest){}
});

});

    
asked by Daniela 10.12.2018 в 14:51
source

1 answer

1

fInicio and fTermino are two local variables of your ASP script, in the line that you are using them you have a conceptual error of jQuery

These lines

var fecini  = $("#<%=fInicio%>").val();
var fecfin  = $("#<%=fTermino%>").val();

and in particular this code what you are doing is to look for an element in the DOM (a div, an input, a button, etc) that is named equal to the value of your variable:

$("#<%=fInicio%>").val();

for example if the value of the varibale is 20181224 is looking for an element that has that id for example <input type="text" id="20181224"> but if it does not exist it does not have a value to assign to your variables.

In this case you must assign them in this way:

var fecini  = "<%=fInicio%>";
var fecfin  = "<%=fTermino%>";

what would be seen for the client as:

var fecini  = "20181210";
var fecfin  = "20181217";
    
answered by 10.12.2018 / 14:59
source