-
-
Save mech/c4dd04ffb432875abf04ced10f65dcc3 to your computer and use it in GitHub Desktop.
Revisions
-
Dean Burge revised this gist
May 13, 2011 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,14 +18,14 @@ // usage: // note, if testing locally, size of file needs to be large enough // to allow time for events to fire $.ajax({ url: "./json.js", type: "GET", dataType: "json", complete: function() { console.log("Completed."); }, progress: function(evt) { if (evt.lengthComputable) { console.log("Loaded " + parseInt( (evt.loaded / evt.total * 100), 10) + "%"); -
Dean Burge revised this gist
May 13, 2011 . 1 changed file with 8 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ (function addXhrProgressEvent($) { var originalXhr = $.ajaxSettings.xhr; $.ajaxSetup({ progress: function() { console.log("standard progress callback"); }, xhr: function() { var req = originalXhr(), that = this; if (req) { if (typeof req.addEventListener == "function") { req.addEventListener("progress", function(evt) { that.progress(evt); },false); @@ -16,18 +16,23 @@ }); })(jQuery); // usage: $.ajax({ url: "./json.js", type: "GET", dataType: "json", complete: function() { console.log("Completed."); }, progress: function(evt) { if (evt.lengthComputable) { console.log("Loaded " + parseInt( (evt.loaded / evt.total * 100), 10) + "%"); } else { console.log("Length not computable."); } } }); -
Dean Burge revised this gist
May 11, 2011 . 1 changed file with 17 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,4 +14,20 @@ return req; } }); })(jQuery); // usage: $.ajax({ url: "./json.js", type: "GET", dataType: "json", progress: function(evt) { if (evt.lengthComputable) { console.log("Loaded " + parseInt( (evt.loaded / evt.totalSize * 100), 10) + "%"); } else { console.log("Length not computable."); } } }); -
Dean Burge created this gist
May 11, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ (function addXhrProgressEvent($) { var originalXhr = $.ajaxSettings.xhr; $.ajaxSetup({ progress: function() { }, xhr: function() { var req = originalXhr(), that = this; if (req) { if (req.addEventListener || req.upload.addEventListener) { req.addEventListener("progress", function(evt) { that.progress(evt); },false); } } return req; } }); })(jQuery);