Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!