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

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

问题描述

我正在面临一些困难,让我的进度条从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
    }
}

这样说,我有困难:


  1. 如何在任务中添加Json部分?

  2. 如何使用给定的Json结果更新进度条?

非常感谢你。 >

Thank you very much.

推荐答案

我已经设法得到这个运行,显然这是我的问题的缺失的拼图。对于任何像这样我这样坚持的人来说,

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进度条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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