本人用 jtemplate 做了数据绑定 而且数据显示了 后台改变的话 前台也即时改变 5秒一次的setTimeout() 调用绑定方法 现在想实现 如果 绑定的值 在后台改变的话 相应的改变 然后td的背景色 闪烁 这个不知道 怎么判断 怎么实现 想请 jtemplate 高人 给予帮助 小弟感激不尽 还有就是 怎么样可以直接在页面加载的时候绑定数据 我的代码如下
<script type="text/javascript" language="javascript">
$(document).ready(function() {
window.setInterval(function() {
$.ajax({
type: "GET",
url: "/event/GetDate",
data: {},
contentType: "application/json",
datatype: "json",
cache: false,
success: function(msg) {
msg = msg.replace(new RegExp('(^|[^\\\\])\\"\\\\/Date\\((-?[0-9]+)\\)\\\\/\\"', 'g'), "$1new Date($2)");
var dateresult = eval(msg);
ApplyTemplate(dateresult);
}
})
}, 5000);
});
function ApplyTemplate(data) {
$('#result').setTemplateElement('template');
$('#result').processTemplate(data);
setTableID();
}
</script>
在页面加载时 调用的话 得等5秒后才显示表格 怎么能让直接显示
<script type="text/javascript" language="javascript">
$(document).ready(function() {
window.setInterval(function() {
$.ajax({
type: "GET",
url: "/event/GetDate",
data: {},
contentType: "application/json",
datatype: "json",
cache: false,
success: function(msg) {
msg = msg.replace(new RegExp('(^|[^\\\\])\\"\\\\/Date\\((-?[0-9]+)\\)\\\\/\\"', 'g'), "$1new Date($2)");
var dateresult = eval(msg);
ApplyTemplate(dateresult);
}
})
}, 5000);
});
function ApplyTemplate(data) {
$('#result').setTemplateElement('template');
$('#result').processTemplate(data);
setTableID();
}
</script>
在页面加载时 调用的话 得等5秒后才显示表格 怎么能让直接显示
解决方案 »
- 菜鸟请教jQuery、、、
- jquery,想点击A标签的时候,弹出一个层出来。A标签是有ID的。该怎么做啊。向各路大虾指教啊。
- 烦请高手解释一下这种语法结构
- js 中,有两个obj对象,obj1,obj2,行数是一样的都是10个,列数不同
- MEIZZ 孟子大侠都出来看看 QQ空间的真实地址是多少?
- onclick问题
- form.all.xxx.value其中all的含义
- 怎么样察看已经清除的上网记录?
- 有没有必要一定要学JavaScript ,如果要学请老鸟们推荐一本全面点的好书!好奇的菜鸟!!
- 如何在客户端判断下拉列表框!!!!!!!!!!!!!
- 这个由中间向四周发散透明渐变的效果,如何用JS实现?
- 如何用JS向WORD中插入数据(求救)
<script type="text/javascript">
$(document).ready(function()
{
f();
window.setInterval("f()", 5000);
}); function f()
{
$.ajax({
type: "GET",
url: "/event/GetDate",
data: {},
contentType: "application/json",
datatype: "json",
cache: false,
success: function(msg)
{
msg = msg.replace(new RegExp('(^|[^\\\\])\\"\\\\/Date\\((-?[0-9]+)\\)\\\\/\\"', 'g'), "$1new Date($2)");
var dateresult = eval(msg);
ApplyTemplate(dateresult);
}
})
}
function ApplyTemplate(data)
{
$('#result').setTemplateElement('template');
$('#result').processTemplate(data);
setTableID();
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<style type="text/css">
.bg1{
background-color:#ff0000;
}
.bg2{
background-color:#00ff00;
}
</style>
<script type="text/javascript">
var ii;
function st()
{
ii=window.setInterval("fc()",1000);
}
function fc()
{
var ttd = document.getElementById('td1');
ttd.className = (ttd.className == "bg1") ? "bg2" : "bg1";
}
function sp()
{
window.clearInterval(ii);
}</script>
</head>
<body ><table><tr><td id="td1" class="bg1">aaaa</td></tr></table><input type="button" value="开始" onclick="st();" />
<input type="button" value="停" onclick="sp();" />
</body>
</html>
这个只是一个简单的列子 我知道 大概是这么解决 但是 问题是不知道 用什么方法 对现在 td里面的值和 json返回过来的值 做比较 然后 背景色闪烁
{
msg = msg.replace(new RegExp('(^|[^\\\\])\\"\\\\/Date\\((-?[0-9]+)\\)\\\\/\\"', 'g'), "$1new Date($2)");
var dateresult = eval(msg);
ApplyTemplate(dateresult);
}
的msg中,别人也看不到数据,只有你自己知道。