gpt4 book ai didi

php - ajax长轮询url/controller/method后面的数字?_xxxx

转载 作者:行者123 更新时间:2023-12-01 04:02:27 25 4
gpt4 key购买 nike

我正在使用 codeigniter,我对我所做的长轮询的 get 查询感到好奇

       function check_new_notif(){
$.ajax({
type:"GET",
url:"/MAIN/AJAX/new_unotif",
async:true,
cache:false,
datatype: "text",
timeout:20000,

success: function(dat){
show_new_notif(dat);
fetch_new_notif();
setTimeout(
check_new_notif,10000
);
},
error: function(XMLHttpRequest,textstatus,errorThrown){
show_new_notif("error");
setTimeout(
check_new_notif,10000
);
}
});

这个号码有什么用?当我在服务器上进行长轮询请求时,firebug 中的链接如下所示

GET /MAIN/Ajax/notification?_=1466062273034

下一个调用它的 /MAIN/Ajax/notification?_=1466062273035 ,增加 1

有人知道这个 ?_=1466062273035 查询的含义吗?

谢谢

最佳答案

当您设置cache: false时,它会将时间戳附加到您的网址

文档:http://api.jquery.com/jquery.ajax/

If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.

关于php - ajax长轮询url/controller/method后面的数字?_xxxx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37853492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com