JS setInterval with an ajax request is auto closing DateTimePicker

I have this code below:

setInterval(function(){
                $.ajax({
                    url: "{{ route('logout_checker')}}",
                    type: "GET",
                    success: function(data){
                        if( data == 0 ){
                            location.reload();
                        }
                    }
                });
            }, 1000);

My problem is that it will auto-close the datetime picker (https://nehakadam.github.io/DateTimePicker/)

the picker will pop up and then close so you can’t select anything.

is there a better way of handling the ajax request since I’m using that to check if there is still an active session and if there’s none it will reload the page so it will go to the login page.

If I remove the ajax request the datetime picker works normally. it’s only when the ajax request is present inside the setInterval that the problem occurs.