I'm trying to fetch user details from a php and updating the div inside the modal with the result.
My problem is I'm getting the result very late. it takes around 10 minutes to update the result. I could not figure out how to resolve this. Meanwhile I've googled for a fix, but unfortunate none of the solutions fix my problem.
My JS
setInterval(function(){
        fetch_program(); //UPDATE
        fetch_user();
    }, 1000);
function fetch_user()
        {
            var action = "fetch_user_data";
            var id = $('#userid').val();
            $.ajax({
                url:"users.php",
                method:"POST",
                data:{id:id, action:action},
                success:function(data)
                {
                    $('#userslist').html(data);
                }
            })
        }
My users.php
if($_POST["action"] == "fetch_user_data")
{
    //sample post for testing
    echo $_POST["id"];
}
The result from the ajax in set inside modal. Please suggest any possible fix
UPDATE:
I have a programe list which is populated by ajax. screenshot below

you can see that there are 2 button add user and delete When I click the add user, it open in a modal with a multiple select. The add user button is done onclick event which will call a function below
function adduser(userid)
    {
        var userid  = userid;
        $("#usermodal").modal("show");
        $('#userselect').data("task",userid);
        $('#userid').val(userid);
    }
In this modal I'm using fetch_user() ajax function to populate the users.
So is this delay caused by any of these function?
