如何使用 JSON 结果更新 Extjs Progress Bar? [英] How to update Extjs Progress Bar with JSON results?

查看:11
本文介绍了如何使用 JSON 结果更新 Extjs Progress Bar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在让进度条从 Json 结果中检索进度并根据每 10 秒的计时器检查更新进度条时遇到了一些困难.

I am facing some difficulties in getting my progress bar to retrieve its progress from Json results and update the progress bar based on the timer check of every 10 seconds.

我可以像这样创建一个 json 结果:

I am able to create a json result like this:

{"success":true, "progress":0.2}

我想一般的想法是,我需要一个间隔设置为 10 秒的任务,并让运行程序运行任务,当进度条开始工作时,运行程序将检查来自 Json 的结果,并且根据需要更新进度条.

I suppose the general idea is that, I need a task with interval set to 10sec, and having the runner to run the task, and when the progress bar starts working, the runner will check on the results from the Json, and update the progress bar as per required.

到目前为止的代码:

var task = {
    run: function(){
        // what to add here?
    },
        interval: 10000
    }
}

话虽如此,我在以下方面遇到了困难:

Having said so, I am having difficulties on:

  1. 如何在任务中添加 Json 部分?
  2. 如何使用给定的 Json 结果更新进度条?

非常感谢.

推荐答案

我已经设法启动并运行它,显然这是我的问题缺少的拼图.对于像我这样坚持下去的人.

I have managed to get this up and running, apparently this is the missing jigsaw to my question. For anyone who are stuck with this like me.

基本上只需添加这部分,它将从您声明的 url 中检索 json 结果,并在成功时更新您的进度条.

Basically just add this portion which will retrieve the json result from your stated url, and on success update your progress bar.

以及要嵌入到您的任务中的最低限度的代码,如下所示:

And the bare minimum code to be embedded within your task like so:

Ext.Ajax.request({
           url: 'getStatus',
           success: function(r) {
                 var i = Ext.decode(r.responseText).progress;
                 progressbar.updateProgress(count +' completed');
           }
});

这篇关于如何使用 JSON 结果更新 Extjs Progress Bar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆