使用Jquery刷新除单个图像之外的所有页面
Using Jquery to refresh all of a page but a single image
我已经阅读了如何使用jquery刷新单个div,但我有一个主要基于表和更新元素的网页。我目前有一个单独的脚本,每1.5秒刷新一次网页,但我的Web_Main文件中有一个静态图像,每次页面刷新时都会闪烁,所以我想在Web_Run文件中使用jquery将该图像从页面刷新中排除。我已经将jquery-1.11.2.min.js文件包含在我的目录文件夹中,并有引用它的头,但我不熟悉jquery,也不知道如何为除图像刷新之外的所有内容创建div,以及我应该将其放在Web_Main脚本还是Web_Run脚本中。
我的Web_Main设置为:
<div class ="refreshpage">
<!-- Rest of page content needing refreshed above --> </div>
<div class = "staticpic">
<img src="picdrawing.png" height="130px" width="99.8%">
</div>
<div class ="refreshpage">
<!-- Rest of page content needing refreshed below--> </div>
我的Web_Run页面
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
<style type="text/css">
</style>
<script>
function showCustomer(str)
{
var xmlhttp;
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari php<!-- include('test.php');--> ?>
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","Web_Main.php",true);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 01 Jan 2000 00:00:00 GMT" );
xmlhttp.send(null);
//showCustomer('ALFKI');
setTimeout(function(){showCustomer('load')}, 1500);
}
</script>
</head>
<body onLoad="showCustomer('Load')">
<div id="txtHint"></div>
</body>
</html>
为什么不尝试使用缓存来缓存静态图像?它仍然会与页面一起"加载",但它不会再闪烁,因为它将立即从缓存中提供服务。
确实没有办法刷新除div或图像之外的所有内容,但在页面上缓存内容只是出于这个原因。因此,您将不必重新加载静态内容。
相关文章:
- css媒体查询请求后刷新jQuery插件
- 刷新jquery中弹出的ui对话框
- 在'之后刷新jQuery Mobile元素;手动'操纵
- 不断刷新 jQuery 数据
- 如何刷新 jquery 移动复选框主题
- 刷新 jQuery 移动范围滑块
- 刷新 jquery 数据表
- 刷新 JQuery Mobile 中的列表视图和复选框
- 使用 ajax 动态刷新 jquery 数据表
- 更改状态以刷新 Jquery 的按钮
- 刷新 jquery 选项卡中的表单字段
- 从DOM刷新jQuery DataTable-无AJAX
- 在Ember.js视图中刷新jQuery绑定的正确方法是什么
- 正在刷新jQuery对话框数据
- 在django中发布一些内容而不刷新(JQuery、AJAX?)
- 如何在页面调整上刷新jQuery Mobile样式
- 如何在动态添加行后刷新JQuery移动表
- 刷新jquery mobile中的弹出内容
- 刷新jquery移动页面时会发生什么
- 如何刷新jQuery.ech()函数