Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Javascript Progess bar collection

By: a guest on Feb 2nd, 2012  |  syntax: JavaScript  |  size: 0.84 KB  |  views: 67  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function onSubmit(upload_id)
  2. {
  3. var xmlhttp;
  4. var test;
  5. test =1;
  6. if (window.XMLHttpRequest)
  7.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  8.   xmlhttp=new XMLHttpRequest();
  9.   }
  10. else
  11.   {// code for IE6, IE5
  12.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  13.   }
  14. xmlhttp.open("GET",'/fileupload/progressbar.php?progress_key='+upload_id, false);
  15. xmlhttp.send();
  16. xmlhttp.onreadystatechange=function()
  17.   {  
  18.   if (xmlhttp.readyState==4 && xmlhttp.status==200)
  19.     {
  20.     if(test=1)
  21.                 {
  22.                         document.getElementById('progress_number').innerHTML=xmlhttp.getResponseHeader("Percent");
  23.                         setTimeout(onSubmit(upload_id), 999);
  24.                 }
  25.         else
  26.                 {
  27.                         document.getElementById('progress_number').innerHTML="Percent more then 100";
  28.                 }
  29.     }
  30.         else
  31.         {
  32.                 document.getElementById('progress_number').innerHTML="Error: Status Code Not 200";
  33.         }
  34.   }
  35. }