87,904
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
function direct() {
$.ajax({
type : "POST",
url : "<%=request.getContextPath()%>/log.do",
});
}
function showlog() {
$("#fm").submit();
setInterval(direct(), 1000);
}
</script>
function direct(){
alert(1);
}
setInterval(direct,1000);
function direct() {
console.info( "time: ", ( new Date() ).getTime() );
}
function showlog() {
setInterval(direct(), 1000);
}
function showlog_2() {
setInterval( direct, 1000 );
}
function showlog_3() {
setInterval( function () {
direct();
}, 1000 );
}
function showlog_4() {
setInterval( "direct()", 1000 );
}
// showlog(); //=> 执行一次
// showlog_2(); //=> 每隔 1000毫秒 执行一次
// showlog_3(); //=> 每隔 1000毫秒 执行一次
// showlog_4(); //=> 每隔 1000毫秒 执行一次
var intervalID = window.setInterval(func, delay[, param1, param2, ...]);
var intervalID = window.setInterval(code, delay);
$(function() {
$("#send").click(function() {
showlog();
$.ajax({
url : "<%=request.getContextPath()%>/addData.do",
type : "POST",
dataType : "json",
data : $("#fm").serialize(),
})
});
});
function showlog() {
setInterval(function() {
$.ajax({
url : "<%=request.getContextPath()%>/log.do",
type : "POST",
});
}, 1000);
}
这样都两个都可以提交到后台,现在是不知道提交到后台action后的return 是什么了,
如果直接用submit的话,可以返回一个jsp页面的呀[/quote]
刷新页面,没有了点击事件,你的自然就没有在执行了[/quote]
$(function() {
$("#send").click(function() {
showlog();
});
});
function showlog() {
setInterval(function() {
$.ajax({
type : "POST",
data:$("#fm").serialize(),
url : "<%=request.getContextPath()%>/log.do",
dataType : "json",
success:function(msg){
showlog();
},
error:function(e){
showlog();
}
});
}, 1000);
}
[/quote]
修改一下
$(function() {
$("#send").click(function() {
showlog();
});
});
function showlog() {
$.ajax({
type : "POST",
data:$("#fm").serialize(),
url : "<%=request.getContextPath()%>/log.do",
dataType : "json",
success:function(msg){
setTimeout(function(){
showlog();
}, 1000);
},
error:function(e){
setTimeout(function(){
showlog();
}, 1000);
}
});
}
$(function() {
$("#send").click(function() {
showlog();
$.ajax({
url : "<%=request.getContextPath()%>/addData.do",
type : "POST",
dataType : "json",
data : $("#fm").serialize(),
})
});
});
function showlog() {
setInterval(function() {
$.ajax({
url : "<%=request.getContextPath()%>/log.do",
type : "POST",
});
}, 1000);
}
这样都两个都可以提交到后台,现在是不知道提交到后台action后的return 是什么了,
如果直接用submit的话,可以返回一个jsp页面的呀[/quote]
刷新页面,没有了点击事件,你的自然就没有在执行了[/quote]
$(function() {
$("#send").click(function() {
showlog();
});
});
function showlog() {
setInterval(function() {
$.ajax({
type : "POST",
data:$("#fm").serialize(),
url : "<%=request.getContextPath()%>/log.do",
dataType : "json",
success:function(msg){
showlog();
},
error:function(e){
showlog();
}
});
}, 1000);
}
$(function() {
$("#send").click(function() {
showlog();
$.ajax({
url : "<%=request.getContextPath()%>/addData.do",
type : "POST",
dataType : "json",
data : $("#fm").serialize(),
})
});
});
function showlog() {
setInterval(function() {
$.ajax({
url : "<%=request.getContextPath()%>/log.do",
type : "POST",
});
}, 1000);
}
这样都两个都可以提交到后台,现在是不知道提交到后台action后的return 是什么了,
如果直接用submit的话,可以返回一个jsp页面的呀[/quote]
刷新页面,没有了点击事件,你的自然就没有在执行了$(function() {
$("#send").click(function() {
showlog();
$.ajax({
url : "<%=request.getContextPath()%>/addData.do",
type : "POST",
dataType : "json",
data : $("#fm").serialize(),
})
});
});
function showlog() {
setInterval(function() {
$.ajax({
url : "<%=request.getContextPath()%>/log.do",
type : "POST",
});
}, 1000);
}
这样都两个都可以提交到后台,现在是不知道提交到后台action后的return 是什么了,
如果直接用submit的话,可以返回一个jsp页面的呀<input id="send" type="button" value="Send" onclick="showlog()">
执行点击后,同时执行
$("#fm").submit();
setInterval(direct(), 1000);
用ajax或者其他,能实现这个功能吗?[/quote]改ajax提交,直接form.submit()提交后都刷新页面了,计时器自然无法继续执行[/quote]
直接用ajax提交怎么写呢?我不太会用.....
这个是我的js内容,我原有的ajax里要定时发送请求,怎么把这个表单的提交在这里写呢?
$(function() {
$("#send").click(function() {
showlog();
});
});
function showlog() {
setInterval(function() {
$.ajax({
type : "POST",
data:$("#fm").serialize(),
url : "<%=request.getContextPath()%>/log.do",
});
}, 1000);
}
<input id="send" type="button" value="Send" onclick="showlog()">
执行点击后,同时执行
$("#fm").submit();
setInterval(direct(), 1000);
用ajax或者其他,能实现这个功能吗?[/quote]改ajax提交,直接form.submit()提交后都刷新页面了,计时器自然无法继续执行<input id="send" type="button" value="Send" onclick="showlog()">
执行点击后,同时执行
$("#fm").submit();
setInterval(direct(), 1000);
用ajax或者其他,能实现这个功能吗? <input id="send" type="button" value="Send" onclick="showlog()">
执行点击后,同时执行
$("#fm").submit();
setInterval(direct(), 1000);
用ajax或者其他,能实现这个功能吗?