jquery加载效果
在我的索引页面中,我有这样的代码:
function cek(){
$container = $("#containermsg").notify();
$.ajax({
url: 'http://192.168.2.45:49/KP/UploadManager/filemover',
cache: false,
success: function(datas){
$("#filemovernotif").html(datas);
}
});
var waktucek = setTimeout("cek()",900000); //satuan ms
}
我想每 90000 毫秒运行一次 url,但它运行得不好,因为每次加载/刷新页面时都会运行此代码。
我还想问一下这段代码的页面加载效果。 url:'http://192.168.2.45:49/KP/UploadManager/filemover'的目的是将许多大文件的内容上传到数据库中,因此它运行大约1分钟或更长时间。当 filemover 执行上传进度时,如何在页面上显示加载进度。我很抱歉我的英语不好。提前致谢。
in my index page, i've code like this :
function cek(){
$container = $("#containermsg").notify();
$.ajax({
url: 'http://192.168.2.45:49/KP/UploadManager/filemover',
cache: false,
success: function(datas){
$("#filemovernotif").html(datas);
}
});
var waktucek = setTimeout("cek()",900000); //satuan ms
}
i want to run the url every 90000 ms, but it not run well, because this code will run every time page loaded/refreshing.
i also want to ask about page loading effect for this code. The objective of url:'http://192.168.2.45:49/KP/UploadManager/filemover' is to uploading the content of many large file into database, so it run about 1 minutes or more. How can i show loading progress on the page while filemover doing uploading progress. i'm sorry for my bad english. Thank's in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:
据我所知,计时器总是运行直到被清除,所以声明一次就足够了。
重构您的代码并在函数外部获取
waktucek
变量。关于加载,一个简单的想法是:在 ajax 函数调用后,在任何地方显示加载图像并成功(上传完成时),只需删除图像:Edit:
As far as I know timer always run until it is cleared out, so declaring it once is enough.
Restructure your code and take
waktucek
variable outside of the function. And about loading, a quick idea is: after ajax function call show a loading image anywhere and inside success(when upload is complete) just remove the image: