Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无缓存的ajax加载页面_Javascript_Jquery_Html_Ajax - Fatal编程技术网

Javascript 无缓存的ajax加载页面

Javascript 无缓存的ajax加载页面,javascript,jquery,html,ajax,Javascript,Jquery,Html,Ajax,我正在使用这个ajax函数将html页面重新加载到web页面中的某个分区 <script> $('#scene_container').load('scene.html', function () { cache: false }); </script> $('#scene_container').load('scene.html',function(){ 缓存:false }); html: 但

我正在使用这个ajax函数将html页面重新加载到web页面中的某个分区

<script>
    $('#scene_container').load('scene.html', function () {

                cache: false
            });
</script>

$('#scene_container').load('scene.html',function(){
缓存:false
});
html:



但大多数情况下,它会加载缓存的网页。如何加载原始html页面?

要根据每个请求控制缓存,需要使用更复杂的函数,如
$.ajax()

在脚本顶部插入以下内容:

$.ajaxSetup ({
    // Disable caching of AJAX responses
    cache: false
});

另一种方法是在url末尾使用这样的唯一id:

$('#scene_container').load('scene.html?uid'+uniqueId());

除非全局禁用load方法,否则防止缓存不可用

但您可以通过向请求URL添加时间参数来确保不会从缓存加载任何数据

url = "scene.html";
url += '?_=' + (new Date()).getTime();

在回调函数中设置
cache=false
。这对ajax调用没有任何影响。您应该使用$.ajax函数禁用缓存。或者@maj建议使用url时间参数。根据文档
不建议使用该参数。
此外,它将禁用所有ajax请求的缓存。我添加了该代码。如果问题再次出现,我会给你回电话的。谢谢您的快速回复。很高兴能帮助您:)@Asanka
url = "scene.html";
url += '?_=' + (new Date()).getTime();