Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter and Jquery AJAX non-responsive when page idle
#1

[eluser]Unknown[/eluser]
Hi folks, my first post here and couldn't find a solution for this little problem.

Essentially my AJAX works perfectly, but when I leave the page to sit idle for a few minutes and come back to the tab
the AJAX doesn't seem to be working. I am using CI 2 and Jquery. Here is the ajax function:

Code:
$(document).ready(function(){
        
        $("#datepicker").datepicker({
        dateFormat: 'yy-mm-dd',
        onSelect: function(){
            
            var visitdate = $('#datepicker').datepicker({ dateFormat: 'yy-mm-dd' }).val();  // here we are taking country id of the selected one.
            console.log(visitdate);

             $.ajax({    
                        url: "dashboard/ajax_appointments", //The url where the server req would we made.
                        async: true,
                        type: "POST", //The type which you want to use: GET/POST
                        data: {
                            
                                date : visitdate,
                                <?php echo $this->security->get_csrf_token_name(); ?>: '<?php echo $this->security->get_csrf_hash(); ?>'
                                //the php here is for the cross-site request forgery built into CodeIgniter.
                                                
                              }, //The variables which are going.
                        dataType: "html", //Return data type (what we expect).
                        
                        //This is the function which will be called if ajax call is successful.
                        success: function(data) {
                            //data is the html of the page where the request is made.
                            $('#bookings-display').html(data);
                        }
                    })
        }
        });

        $("#date").change(function(){ //any select change on the dropdown with id country trigger this code
            
  
        });
        

        
    });
    
    $(function() {
$( "#date" ).datepicker({ dateFormat: "yy-mm-dd" });
        });

Please help a noob Smile




Theme © iAndrew 2016 - Forum software by © MyBB