keep all records for every AJAX call in VB.NET

0

It sent through AJAX values according to the checkboxes that a user selects to another page2 that receives them, and processes them to a BD, the problem is that I have a cycle each with jquery for the sending of the value that the user selected and if the user selects 3 ckeck the page2 is called 3 times to send the value of the check, every time that the page is called2 I draw an HTML table to place the values that correspond to the value of the check that was selected, How can I keep the values which are drawn in the html table of each call to page2? since if 3 checkboxes are selected the table is drawn once data appears and disappears, then the second time data appears and disappears, and finally the third time data appears and the data of the latter is displayed, what I require is that they appear the 3 tables

    $("#btnEnviar").click(function () {        
        var selected = '';
        var varValorCheck = '';
        $("#form1 input[type=checkbox]").each(function () {
            if (this.checked) {
                selected += $(this).val() + ', ';
                varValorCheck = $(this).val()
                //alert(varValorCheck);
                EnviarReporte(varValorCheck,selected);
            }
        });

        if (selected == '')

            alert('Debes seleccionar al menos una opción.');

        return false;
    });

    function EnviarReporte(varValorCheck, varAcumulador) {
      
      var facturaSeleccionada = varValorCheck
      var acumuladorFact = varAcumulador


      var cargando = $("#muestraSeccion").html("<center><img  src='../Images/cargando1.gif' height='50px' width='50px'/><br/>Un momento por favor...<center>");

      $.ajax({
        type: 'POST',
        url: 'guardarEnvio',
        data: {
          "facturaEnvio": facturaSeleccionada,
          "acumuladorFactura": acumuladorFact
        },
        success: function(resultado) {

          $("#muestraSeccion").hide().html(resultado).fadeIn("fast");


        },
        error: function(jqXHR, textStatus, errorThrown) {
          console.log(jqXHR, textStatus, errorThrown);
          if (jqXHR.status === 0) {

            alert('Not connect: Verify Network.=(');

          } else if (jqXHR.status == 404) {

            alert('Requested page not found [404].');

          } else if (jqXHR.status == 500) {

            alert('Error Interno del Servidor [500].');

          } else if (textStatus === 'parsererror') {

            alert('Requested JSON parse failed.');

          } else if (textStatus === 'timeout') {

            alert('Time out error.');

          } else if (textStatus === 'abort') {

            alert('Ajax request aborted.');

          } else {

            alert('Uncaught Error: ' + jqXHR.responseText);

          }

        }
      });
    }

@Code
    PageData("Title") = "Escriba el título aquí"
    
    Dim db = Database.Open("empresaFactura")
    Dim factura = Request.Form("facturaEnvio")
    Dim acumulador = Request.Form("acumuladorFactura")
    Dim fecha = DateTime.Now().ToString("yyyy-MM-dd hh:mm:ss")

    
    Dim verFactura As New funciones()
    Dim resgistrosFactura = verFactura.DatosFacturaEnvio(factura)
        
    Dim cuerpoCorreo As String
    
    cuerpoCorreo = "<table style='border-color: #666;margin: 0 auto;' cellpadding='10' >" & _
              "<tr style='background: #eee;'><thead> <td><strong>Factura</strong></td> <td><strong>Fecha<strong></td> </thead></tr>"
    
    
    For Each item2 In resgistrosFactura
        cuerpoCorreo += "<tr> <td>" & item2.nombre & "</td> <td>" & item2.ap & "</td> <td>" & item2.am & "</td> </tr>"
    Next
    
    
    
    cuerpoCorreo += "</table>"
        
    Response.Write(cuerpoCorreo)

End Code

    
asked by Ivxn 30.06.2016 в 20:57
source

1 answer

1

I had implemented something related to what you plan keeping the data selected or entered values in the table

[GridView] Keep checkbox during paging

[ASP.NET] Keep information when changing pages

The idea is to keep the data on the server side and join them to the new ones when you browse from one page to another.

Analyze the articles and you will see that you can on the server mark the data and send the marks you had previously when you return to the previous page.

What I propose involves maintaining the data on the server side, working from there and sending them to the UI as a response from json, to access the session from% safe% you must use the WebMethod

    
answered by 29.08.2016 / 23:09
source