Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

274
Visualizações
Ajax table infinite reload when using form tag in HTML

I created an application to do date filtering, so when the date was changed the table will reload. It's working fine before, until I tried to add the export button (excel export using phpspreadsheet) with the form tag. When I change the date, the table doing infinite reload like this picture until I'm doing any click.

enter image description here

I think there's no problem with the controller code. The export function is working fine too, the problem just why the table doing infinite reload when I added the form tag.

Ajax code:

<script type="text/javascript">
    $(document).ready(function() {
        var table = $('#table').DataTable({
            "serverSide": true,
            "ajax": {
                url: "<?= base_url('user/pagination') ?>",
                type: "POST",
                data: {
                    start: function() {
                        return $('#start').val()
                    },
                    end: function() {
                        return $('#end').val()
                    }
                },
            },
        });

        $('#start, #end').on('keyup change', function(e) {
            table.ajax.reload(); // I used this to reload the table when the date changed
        });
    });
</script>

Html form

<label>Date Filter</label>
<form action="<?php echo base_url('user/export'); ?>" method="POST" targets="_blank">
    <div class="form-group col-md-6 form-float">
        <input type="date" name="start" id="start" class="form-control">
        <input type="date" name="end" id="end" class="form-control">
        <input type="submit" class="form-control" value="Export Data to Excel">
    </div>
</form>

Any solutions for it? or there's some alternative way to added my export button? Thanks!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda