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。

更多相关文章

  1. jQuery - 加载gif的延迟显示
  2. Ajax/jQuery -在页面加载时将网页内容加载到div中?
  3. 点击JSON数据加载Galleria画廊。我需要新鲜的眼睛来看我的错误
  4. 在执行ajax时显示加载图像
  5. jQuery实例(ajax通信和动态加载二级菜单)
  6. 当AJAX响应来自PHP文件时,如何显示以消息为中心的加载器图像&防止
  7. 通过jQuery设置全局Ajax加载时呈现Loading
  8. 文字效果 - 图像到css / jQuery
  9. 加载函数加载页面但不能对数据执行任何操作

随机推荐

  1. Cocos2d-x 3.0 开发(十七)使用Cocos2d-x 3.
  2. Android源码在UBUNTU编译全过程
  3. 空对象引用错误:使用SQLite的Android Stud
  4. onActivityResult与singleTask或singleIn
  5. Android_照相机Camera_调用系统照…
  6. Android[中级教程] 深入剖析Android消息
  7. 拍照后获取不了图片!
  8. android滑动菜单SlidingMenu
  9. Android BroadcastReceiver中播放提示语
  10. linux android 如何把android项目打成jar