ExtJs 진행률 표시줄(폴링)
                                            
 6314 단어  ExtJs
                    
      Ext.onReady(function () {
            Ext.get('mb').on('click', function () {
                Ext.Ajax.request({
                    url: root + "/Test/GetCount",
                    success: function (response) {
                        var sum = response.responseText;
                        Ext.MessageBox.show({
                            title: '  ',
                            msg: '    ...',
                            progressText: '',
                            width: 300,
                            progress: true,
                            closable: false,
                            animateTarget: 'mb'
                        });
                        f(sum);
                    },
                    failure: function () {
                    }
                });
            });
        });
        function f(v) {
            Ext.Ajax.request({
                url: root + "/Test/GetCurrentCount",
                success: function (response) {
                    var curnum = response.responseText;
                    if (curnum == 0) {
                        Ext.MessageBox.hide();
                    }
                    else {
                        var i = (v - curnum) / v;
                        Ext.MessageBox.updateProgress(i, Math.round(100 * i) + '% completed');
                        setTimeout(f(v), 1000);
                    }
                }
            });
        }  서버 시간 소모 작업:
 1 public class TestController : Controller
 2     {
 3         private static int _count = 0;
 4         public int GetCount()
 5         {
 6             _count = 10;
 7             ThreadStart ts = new ThreadStart(RunBackThread);
 8             Thread td = new Thread(ts);
 9             td.Start();
10             return _count;
11         }
12         public int GetCurrentCount()
13         {
14             return _count;
15         }
16         public void RunBackThread()
17         {
18             while (_count > 0)
19             {
20                 Thread.Sleep(1000);
21                 _count--;
22             }
23         }
24     }  이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
문자열 길이를 계산하고 중국어로 두 개를 계산합니다.텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.