php - 刷新页面时如何自动清除缓存?
问题描述
我正在使用 php + jquery 构建一个网站。
在一个jquery ajax页面中,每次ctrl+F5都要清缓存,否则这个页面的按钮不能点击。
我的想法是通过“window.location.reload(true);”强制刷新此页面 ,但我无法同时清除缓存!</p>
单击按钮而不是ctrl + F5后是否有任何Jquery或其他东西可以自动清除缓存?
我的代码如下:
...
$("[id = One_Click_Accept]").click(function(){
...
$.ajax({
url: WebsitePath + '/accreditation_check/' + CurAccreditationId,
data: {
accreditation_id: CurAccreditationId,
IsAccredited: 1,
CheckerName:$('#CheckerName').val(),
CheckTime: Math.round(new Date().getTime()/1000).toString(), //it need a 10 digit timestamp to save to the db.
TheCountry : TheCountry,
TheSchool: TheSchool,
TheDegree: TheDegree,
TheMajor: TheMajor,
YearOfGraduation: YearOfGraduation
},
type: "POST",
dataType: 'json',
cache: false,
success: function (Result) {
if (Result.Status == 1) {
alert('认证成功');
} else {
alert('认证失败');
$("#One_Click_Accept").val('再次认证');
}
},
error: function () {
alert('认证失败');
$("#One_Click_Accept").val('再次认证');
}
});
}
//window.location.reload(true);
});
解决方案
谢谢你们!我通过使用“setTimeout(function()”来延迟加载时间来解决它。不仅如此,我还必须使用不同的选择器,它看起来像“$(document).on('click',"[id = One_Click_Accept ]",函数(e)"。
推荐阅读
- database - SDO_WITHIN_DISTANCE 的 Oracle Spatial 搜索查询错误(基于纬度/经度)
- pandas - pandas_udf 与 pyspark 3.0 的 scipiy.find_peaks 结果不一致
- docker - 如何从 Docker Hub(私有存储库)获取所有标签作为 Shell 脚本
- sql - 如何在Oracle中为不同的选择生成序列号
- docusignapi - How to use own c# class or DLL in docusign workflow
- html - 下拉导航仅显示整个父元素是否随它展开
- docker - Docker EROFS:只读文件系统,取消链接 webpack-dev-server
- docker - 如何将 AuthKey 插件添加到 Geoserver (localhost:8600)
- linux - 如何让 g++ 正确使用我自己的 glibc 构建的头文件?
- c++ - 在运算符重载定义中使用成员函数(const 错误)