Click here to Skip to main content
15,868,000 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I wanted to call a function getByClassAllreceipts on dropdown change event.

I have multiple dropdown bind to change event, the problem is that the function getByClassAllreceipts is called for every event and the dataTable doesn't change data of each event.

In simple word on this $("#classid, #feetypeid, #listtype").change event the DataTable data doesn't get changed, even in the preview it gets the data correctly in the last called ajax request.

Hope I have cleared the problem I am facing.

Please help.

What I have tried:

PHP
$("#classid, #feetypeid, #listtype").change(function(){
        var listtype = $("#listtype").val();
        var classid = $("#classid").val();
        var feetypeid = $("#feetypeid").val();
        $.ajax({
                url : "<?php echo site_url('FeeReceipt/getByClassAllreceipts'); ?>",
                method : "POST",           
                data : {classid: classid, feetypeid: feetypeid,listtype : listtype},
                async : true,
                dataType : 'json',
                success: function(data)
                {

            dataTbl.DataTable({            
            data : data, 
            columns: [
                { data: 'id'},
                { data: 'rollno'},
				{ data: 'name'},
				{ data: 'age'},
                
                return data;
                }
            }
                ]
           
         });
            }
                                
        });
        return false; 
    });
Posted
Updated 17-Jul-22 7:48am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900