File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -232,27 +232,30 @@ $.fn.ajaxSubmit = function(options) {
232232 cache : false ,
233233 type : 'POST'
234234 } ) ;
235-
235+
236236 if ( options . uploadProgress ) {
237237 // workaround because jqXHR does not expose upload property
238238 s . xhr = function ( ) {
239239 var xhr = jQuery . ajaxSettings . xhr ( ) ;
240240 if ( xhr . upload ) {
241241 xhr . upload . onprogress = function ( event ) {
242242 var percent = 0 ;
243- if ( event . lengthComputable )
244- percent = parseInt ( ( event . position / event . total ) * 100 , 10 ) ;
245- options . uploadProgress ( event , event . position , event . total , percent ) ;
246- } ;
243+ var position = event . loaded || event . position ; /*event.position is deprecated*/
244+ var total = event . total ;
245+ if ( event . lengthComputable ) {
246+ percent = Math . ceil ( position / total * 100 ) ;
247+ }
248+ options . uploadProgress ( event , position , total , percent ) ;
249+ }
247250 }
248251 return xhr ;
249- } ;
252+ }
250253 }
251254
252- s . data = null ;
253- var beforeSend = s . beforeSend ;
254- s . beforeSend = function ( xhr , o ) {
255- o . data = formdata ;
255+ s . data = null ;
256+ var beforeSend = s . beforeSend ;
257+ s . beforeSend = function ( xhr , o ) {
258+ o . data = formdata ;
256259 if ( beforeSend )
257260 beforeSend . call ( o , xhr , options ) ;
258261 } ;
You can’t perform that action at this time.
0 commit comments