php - process popup on ajax and don't display on html

64

I have a bit of a problem . I can succesfully sort my date range now but the problem is that it doesn't display on my datatable it's always has this process popup box

enter image description here

But i have the data as you can see here on the image below

enter image description here

I am usingCodeIgniter 3.x by the way. Here's my code

$('.input-daterange').datepicker({
todayBtn: 'linked',
format: "yyyy-mm-dd",
autoclose: true
});

function fetch_data(start_date='', end_date=''){
var dataTable = $('#table-sales').DataTable({
    "processing": true,
    "serverSide": true,
    "order":[],
    "ajax":{
        url: "sales/rangeDates",
        type: "POST",
        data:{
            'start_date':start_date, 'end_date':end_date
        },
        success:function(data){
            $('#table-sales').html(data);
        }
    }
});
}

$('#search').click(function(){

var inv_type = $('#invType').val();
var start_date = $('#start_date').val();
var end_date = $('#end_date').val();


if(start_date != '' && end_date != '' && inv_type != 0){
    $('#table-sales').DataTable().destroy();
    fetch_data(start_date,end_date);
}else{
    alert('Both Date is Required and Choose what to show!');
}

});

Please let me know if there's a missing information I need to show you guys. Thank you.

RESPONSE:

enter image description here

262

Answer

Solution:

Update your fetch data code

function fetch_data(start_date='', end_date=''){
var dataTable = $('#table-sales').DataTable({
"processing": true,
"serverSide": true,
"order":[],
"ajax":{
    url: "sales/rangeDates",
    type: "POST",
    data:{
        'start_date':start_date, 'end_date':end_date
    },
    success:function(data){
        $('#table-sales').html(data);
        $("#table-sales_processing").css("visibility","hidden");
    }
 }
});
}

People are also looking for solutions to the problem: Return PHP array to JavaScript file with AJAX

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.