开始停止恢复 AJAX
start stop resume ajax
这是我废弃的脚本,它只是一个基本的停止时间监视脚本,我想输入一些有关如何添加简历和开始按钮的信息。我希望能够在启动时发送 ajax 调用,当它停止时暂停时。
var timer;
$(function () {
$('#dateTime').html(getDateTime());
timer = setTimeout(function () {
update();
}, 1000);
$('#btn').click(function () {
clearTimeout(timer);
var currentdatetime = getDateTime();
});
});
function update() {
$('#dateTime').html(getDateTime());
timer = setTimeout(function () {
update();
}, 1000);
}
function getDateTime() {
var currentdate = new Date();
var datetime = "Timer: " + currentdate.getDate() + "/" + (currentdate.getMonth() + 1) + "/" + currentdate.getFullYear() + " " + currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds();
return datetime;
}
var timer;
function resume() {
update();
$('#resume').off("click", resume);
$('#pause').on("click", pause);
// make start / resume ajax call here
}
function pause() {
clearTimeout(timer);
$('#resume').on("click", resume);
$('#pause').off("click", pause);
// make pause / stop ajax call here
}
function update() {
$('#dateTime').html(getDateTime());
timer = setTimeout(function () {
update();
}, 1000);
}
function getDateTime() {
var currentdate = new Date();
var datetime = "Timer: " + currentdate.getDate() + "/" + (currentdate.getMonth() + 1) + "/" + currentdate.getFullYear() + " " + currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds();
return datetime;
}
$(function () {
resume();
});
相关文章:
- 无法在通过jQuery的ajax加载的页面中执行javascript
- 如何通过ajax刷新JSF填充的javascript变量
- 如何在php文件中获取$.post-ajax传递的值
- Replacing $ .ajax?
- 在使用Polymer'加载所有json文件后执行方法;s的核心ajax
- Ajax发布表单序列化,发布引号'
- 通过Ajax将JavaScript函数传递给PHP文件
- ajax请求的顺序总是不同的
- 可以't使用Polymer's的核心ajax
- 开始停止恢复 AJAX
- 如何恢复 ajax 中按钮的初始值请求成功
- 在 ajax 调用之前替换按钮,然后在调用后恢复
- HTML In Page 在使用 AJAX 更改内部 HTML 后恢复为原始 HTML
- Wordpress中的恢复变量Ajax
- $.ajax-jsonGET在页面加载后恢复所有jquery
- 基于AJAX的导航和浏览器恢复
- 在取消时从ajax恢复到第一次加载值
- jQuery UI可排序-在ajax错误后恢复原始位置
- Ajax:将表单恢复到初始值
- 如何在IE11中ajax图像加载后恢复滚动位置