Untitled


SUBMITTED BY: Guest

DATE: Oct. 25, 2013, 9:56 p.m.

FORMAT: Text only

SIZE: 1.2 kB

HITS: 93791

  1. <div class="progress progress-striped active">
  2. <div class="progress-bar" role="progressbar" aria-valuenow="65" aria-valuemin="0" aria-valuemax="100" style="width: 65%">
  3. <span class="sr-only">65% Complete</span>
  4. </div>
  5. </div>
  6. $.ajax({
  7. xhr: function(){
  8. var xhr = new window.XMLHttpRequest();
  9. //Upload progress
  10. xhr.upload.addEventListener("progress", function(evt){
  11. if (evt.lengthComputable) {
  12. var percentComplete = evt.loaded / evt.total;
  13. //Do something with upload progress
  14. console.log(percentComplete);
  15. }
  16. }, false);
  17. //Download progress
  18. xhr.addEventListener("progress", function(evt){
  19. if (evt.lengthComputable) {
  20. var percentComplete = evt.loaded / evt.total;
  21. //Do something with download progress
  22. console.log(percentComplete);
  23. }
  24. }, false);
  25. return xhr;
  26. },
  27. type: 'POST',
  28. url: "/",
  29. data: {},
  30. success: function(data){
  31. //Do something success-ish
  32. }
  33. });

comments powered by Disqus