ajax cache false无法加载图片
16lz
2021-01-22
i want to load image from server when ever i click a button by using get request but every time i load using ajax it bring cached image not the latest one
我想通过使用get请点击按钮时从服务器加载图像但是每次使用ajax加载时它都会带来缓存的图像而不是最新的图像
here is my code
这是我的代码
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$.ajaxSetup({ url:"cap", cache: false });
$("#btn").click(function(){
$("#mydiv").load("cap");
});
});
</script>
<div style="display:block;margin-bottom:20px;margin-top:20px;">
<div id='mydiv'></div>
</div>
<button id='btn' > reload </button>
1 个解决方案
#1
0
Why don't you integrate a <img>
tag into the <div id='mydiv'></div>
? Then you could change the src
attribute in order to change the image and you don't need to use ajax.
为什么不将标签整合到
中?然后你可以更改src属性以更改图像,而不需要使用ajax。更多相关文章
- jQuery - 加载gif的延迟显示
- Ajax/jQuery -在页面加载时将网页内容加载到div中?
- 点击JSON数据加载Galleria画廊。我需要新鲜的眼睛来看我的错误
- 在执行ajax时显示加载图像
- jQuery实例(ajax通信和动态加载二级菜单)
- 当AJAX响应来自PHP文件时,如何显示以消息为中心的加载器图像&防止
- 通过jQuery设置全局Ajax加载时呈现Loading
- 文字效果 - 图像到css / jQuery
- 加载函数加载页面但不能对数据执行任何操作