我正在构建一个使用php + jquery的网站。
在jquery页面中,我必须每次使用ctrl +F5清除缓存,否则无法单击此页面的按钮。
我的想法是用“window.location.reload(真)”来强制刷新这个页面,但是我不能同时清除缓存!
在单击按钮而不是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);
});发布于 2020-03-12 08:30:30
谢谢你们!我通过使用“setTimeout(function())”来延迟加载时间来解决这个问题。不仅如此,我还必须使用不同的选择器,它看起来像"$(document).on('click',"id = One_Click_Accept“,function(e)”)。
https://stackoverflow.com/questions/60294838
复制相似问题