code_junkie

How to display the progress of a server script in jQuery?

Nov 10th, 2011
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. function calculateTotals() {
  2. $('#results').load('getResults.php', null, showStatusFinished);
  3. showLoadStatus();
  4. }
  5.  
  6. function showLoadStatus() {
  7. $('#status').html('');
  8. }
  9.  
  10.  
  11. function showStatusFinished() {
  12. $('#status').html('Finished.');
  13. }
  14.  
  15. function getStatus() {
  16. $.getJSON("/status.php",{"session":0, "requestID":12345},
  17. function(data) { //data is the returned JSON object from the server {name:"value"}
  18. setStatus(data.status);
  19. window.setTimeout("getStatus()",intervalInMS)
  20. });
  21. }
  22.  
  23. {"status":"We are done row 1040/45983459"}
Add Comment
Please, Sign In to add comment