我正在使用rack offline for offline方法,但是在我的一个js文件中,我需要避免一个ajax调用的缓存,因为同样的js用于离线和在线。但在页面重新加载后,使用相同的缓存,当在线?有没有其他方法可以避免这种缓存?
$('#cSearch').keyup(function(e){
var number = $(this).val();
var urlVal = "/customer/get_details";
$.ajax({
cache: false,
url: urlVal,
data: {"term": number, t: Math.random() },
success: function(){
}
});
});发布于 2015-12-14 17:54:56
您可以使用var检查系统是否具有到web的连接:
$('#cSearch').keyup(function(e){
var number = $(this).val();
var urlVal = "/customer/get_details";
var cache = window.navigator.onLine ? false : true; // check if sys is online
$.ajax({
cache: cache, // <-----use it here
url: urlVal,
data: {"term": number, t: Math.random() },
success: function(){
}
});
});https://stackoverflow.com/questions/34263822
复制相似问题