Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Check for server response being null if testing locally (processed to…

…o quickly), and correctly append X-Progress-ID with ampersand when there's already a querystring.
  • Loading branch information...
commit 12f1e2c666b83bd4e7a39141d7a2245bfa80162d 1 parent 862aa0a
@1stvamp 1stvamp authored
Showing with 21 additions and 17 deletions.
  1. +21 −17 jquery.uploadProgress.js
View
38 jquery.uploadProgress.js
@@ -75,7 +75,9 @@
var action = $(this).attr("action").replace(old_id[1], uuid);
$(this).attr("action", action);
} else {
- $(this).attr("action", jQuery(this).attr("action") + "?X-Progress-ID=" + uuid);
+ var action = jQuery(this).attr("action");
+ var action_sep = (action.lastIndexOf("?") != -1) ? "&": "?";
+ $(this).attr("action", action + action_sep + "X-Progress-ID=" + uuid);
}
var uploadProgress = $.browser.safari ? progressFrame.jQuery.uploadProgress : jQuery.uploadProgress;
options.timer = window.setInterval(function() { uploadProgress(this, options) }, options.interval);
@@ -89,25 +91,27 @@ jQuery.uploadProgress = function(e, options) {
url: options.progressUrl + "?X-Progress-ID=" + options.uuid,
dataType: options.dataType,
success: function(upload) {
- if (upload.state == 'uploading') {
- upload.percents = Math.floor((upload.received / upload.size)*1000)/10;
+ if (upload) {
+ switch (upload.state) {
+ case 'uploading':
+ upload.percents = Math.floor((upload.received / upload.size)*1000)/10;
- var bar = $.browser.safari ? $(options.progressBar, parent.document) : $(options.progressBar);
- bar.css({width: upload.percents+'%'});
- options.uploading(upload);
- }
-
- if (upload.state == 'done' || upload.state == 'error') {
- window.clearTimeout(options.timer);
- options.complete(upload);
- }
+ var bar = $.browser.safari ? $(options.progressBar, parent.document) : $(options.progressBar);
+ bar.css({width: upload.percents+'%'});
+ options.uploading(upload);
+ break;
- if (upload.state == 'done') {
- options.success(upload);
- }
+ case 'done':
+ options.success(upload);
+ case 'error':
+ window.clearTimeout(options.timer);
+ options.complete(upload);
+ break;
+ }
- if (upload.state == 'error') {
- options.error(upload);
+ if (upload.state == 'error') {
+ options.error(upload);
+ }
}
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.