简体   繁体   English

刷新具有进度条的html表

[英]Refreshing a html table which has a progress bar

I have a requirement which is nothing but progress bar inside a table column which should be active. 我有一个要求,不过就是应该处于活动状态的表列中的进度条。 I will have plenty of bootstrap progress bar(Say some 10) and I am using spring mvc in server side. 我将有很多引导进度条(说一些10),并且我在服务器端使用spring mvc。 Now the problem is I don't know how to update the progress bar constantly(Say some every 10secs) without refreshing the entire page, to be more precise I want the html table to be refreshed every 10 secs, it should hit the server and the value of the progress bar should be applied to the progress bar inside the html table. 现在的问题是我不知道如何在不刷新整个页面的情况下不断更新进度条(每10秒说一次),更准确地说,我希望html表每10秒刷新一次,它应该在服务器上进度条的值应应用于html表内的进度条。

Can some one please suggest how to do this requirement, I am really in need of help and any example links which would actually help me to achieve this. 有人可以建议一下如何做到这一点吗,我真的很需要帮助,并且实际上需要任何示例链接才能帮助我实现这一要求。 I am not expert in javascript/ajax( I guess its possible to achieve this using ajax, I could not find any examples in google either). 我不是javascript / ajax方面的专家(我想有可能使用ajax实现此目的,我也无法在google中找到任何示例)。 If this is achievable using javascript(nor ajax) any example links would actually help me a lot. 如果可以使用javascript(nor ajax)做到这一点,那么任何示例链接实际上都会对我有很大帮助。 Thanks in advance :) 提前致谢 :)

On the javascript side you would have a js function making a $.ajax call 在javascript方面,您将有一个js函数进行$ .ajax调用

function getProgress(){
  $.ajax({
    url: "/myurl",
    success : function(data){
      //TODO here update your progressbar data=XX returned by spring
      if(data!=100){
         setTimeout(getProgress,10000);//reschedule again until job finished
      }
    }
  })
}
setTimeout(getProgress,10000);

on the spring side : 在弹簧侧:

in a controller you will return the progress : 在控制器中,您将返回进度:

@RequestMapping("/myurl")
public @ResponseBody String getProgrees(){
  //TODO business logic
  return "XX";//0-100
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM