| 893 | pipe, |
| 894 | options = that._getAJAXSettings(data), |
| 895 | send = function () { |
| 896 | that._sending += 1; |
| 897 | // Set timer for bitrate progress calculation: |
| 898 | options._bitrateTimer = new that._BitrateTimer(); |
| 899 | jqXHR = jqXHR || ( |
| 900 | ((aborted || that._trigger( |
| 901 | 'send', |
| 902 | $.Event('send', {delegatedEvent: e}), |
| 903 | options |
| 904 | ) === false) && |
| 905 | that._getXHRPromise(false, options.context, aborted)) || |
| 906 | that._chunkedUpload(options) || $.ajax(options) |
| 907 | ).done(function (result, textStatus, jqXHR) { |
| 908 | that._onDone(result, textStatus, jqXHR, options); |
| 909 | }).fail(function (jqXHR, textStatus, errorThrown) { |
| 910 | that._onFail(jqXHR, textStatus, errorThrown, options); |
| 911 | }).always(function (jqXHRorResult, textStatus, jqXHRorError) { |
| 912 | that._onAlways( |
| 913 | jqXHRorResult, |
| 914 | textStatus, |
| 915 | jqXHRorError, |
| 916 | options |
| 917 | ); |
| 918 | that._sending -= 1; |
| 919 | that._active -= 1; |
| 920 | if (options.limitConcurrentUploads && |
| 921 | options.limitConcurrentUploads > that._sending) { |
| 922 | // Start the next queued upload, |
| 923 | // that has not been aborted: |
| 924 | var nextSlot = that._slots.shift(); |
| 925 | while (nextSlot) { |
| 926 | if (that._getDeferredState(nextSlot) === 'pending') { |
| 927 | nextSlot.resolve(); |
| 928 | break; |
| 929 | } |
| 930 | nextSlot = that._slots.shift(); |
| 931 | } |
| 932 | } |
| 933 | if (that._active === 0) { |
| 934 | // The stop callback is triggered when all uploads have |
| 935 | // been completed, equivalent to the global ajaxStop event: |
| 936 | that._trigger('stop'); |
| 937 | } |
| 938 | }); |
| 939 | return jqXHR; |
| 940 | }; |
| 941 | this._beforeSend(e, options); |
| 942 | if (this.options.sequentialUploads || |
| 943 | (this.options.limitConcurrentUploads && |