1

actually I am developing a application using Spring MVC, in one case I have to make the user to wait for the results by displaying a page..and once the back end processes the request..the results will be loaded. Can anyone please tell me how can I achieve that?

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
user503285
  • 125
  • 3
  • 14

2 Answers2

2

I'd say this is more of a javascript solution than necessarily a Spring one.

Lets say you're waiting on a request from the back end process, you could use the solution here to wait for a response while your back end produces the data you require.

The code below would show the code within the loaderImage id (say it's a div in html), then hide it when the success is loaded. The ajax request would just be whatever POST or GET you use to get to your back end controller.

$('#loaderImage').show();
$.ajax({
    // Other ajax parameters
    success: function () {
       // hiding the image here
       $('#loaderImage').hide();
    }
});
Community
  • 1
  • 1
David
  • 19,577
  • 28
  • 108
  • 128
  • actually there should be timeout also for displaying the page..the scenario goes like this. 1) First the user enters the login data and submit..2) it should load a page with current status 3) in the back end after processing the request it should redirect to the browser with the output. – user503285 May 07 '13 at 14:48
  • Ah ok - so in the back end you want to specify a timeout? I'd expect Spring to return a new view for the ajax to redirect to. If you want to specify a server side timeout, I'd recommend the inbuilt functionality with Spring Security http://stackoverflow.com/questions/12082677/setting-session-timeout-in-spring-mvc – David May 07 '13 at 14:59
0

You can use

  window.onload();


<!doctype html>
<html>
  <head>
    <title>onload test</title>
    <script>
      function load() {
        alert("load event detected!");
      }
      window.onload = load;
    </script>
  </head>
  <body>
    <p>The load event fires when the document has finished loading!</p>
  </body>
</html>

SO there you can remove your loading div or html.

https://developer.mozilla.org/en-US/docs/DOM/window.onload

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307