【发布时间】:2010-03-19 01:52:53
【问题描述】:
我想在 ajax 请求触发和完成时使用 jquery ui 进度条显示进度。问题是我不知道如何根据 ajax 请求的进度设置进度条的值。这是一个开始的代码:
function ajaxnews()
{
$('.newstabs a').click(function(e){
var section = $(this).attr('id');
var url = base + 'news/section/' + section;
$.ajax({
url : url,
dataTye : 'html',
start : loadNews,
success : fillNews
});
});
}
// start callback functions
function loadNews()
{
$('#progressbar').fadeIn();
$('#progressbar').progressbar({ //how shoud I set the values here});
}
function fillNews()
{
$('#progressbar').progressbar('option', 'value', ?? /* how do I find this?*/);
$('#progressbar').fadeOut();
}
【问题讨论】:
-
可以通过绑定进度事件来获取下载状态。查看此示例 - gist.github.com/nebirhos/3892018
-
这里我实现了 proggressbar(js-control-files-uploader.itweb-projects.com),但我使用 xhr.upload.addEventListener('progress', ... Github : github.com/dimitardanailov/js-control-files-uploader/blob/…
标签: javascript jquery-ui jquery