weixin_33701564 2020-02-02 11:11 采纳率: 0%
浏览 33

PHP的模式阿贾克斯晚响应

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 programme list

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 outlook无法配置成功
    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题