use jqXHR.fail() to check for failures

Signed-off-by: Artur Neumann <info@individual-it.net>
This commit is contained in:
Artur Neumann 2017-04-27 10:55:41 +05:45
parent 4dab01d9ed
commit 79c760a10c
1 changed files with 9 additions and 10 deletions

View File

@ -90,16 +90,15 @@
}, },
done: function(e, data) { done: function(e, data) {
// Created // Created
if (data.jqXHR.status === 201) {
var mimeTypeUrl = OC.MimeType.getIconUrl(data.files[0].type); var mimeTypeUrl = OC.MimeType.getIconUrl(data.files[0].type);
$('#public-upload ul li[data-name="' + escapeHTML(data.files[0].name) + '"]').html('<img src="' + escapeHTML(mimeTypeUrl) + '"/> ' + escapeHTML(data.files[0].name)); $('#public-upload ul li[data-name="' + escapeHTML(data.files[0].name) + '"]').html('<img src="' + escapeHTML(mimeTypeUrl) + '"/> ' + escapeHTML(data.files[0].name));
$('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="tooltip"]').tooltip();
} else { },
fail: function(e, data, errorThrown) {
var name = data.files[0].name; var name = data.files[0].name;
OC.Notification.showTemporary(OC.L10N.translate('files_sharing', 'Could not upload "{filename}"', {filename: name})); OC.Notification.showTemporary(OC.L10N.translate('files_sharing', 'Could not upload "{filename}"', {filename: name}));
$('#public-upload ul li[data-name="' + escapeHTML(name) + '"]').html(output({isUploading: false, name: escapeHTML(name)})); $('#public-upload ul li[data-name="' + escapeHTML(name) + '"]').html(output({isUploading: false, name: escapeHTML(name)}));
$('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="tooltip"]').tooltip();
}
}, },
progressall: function (e, data) { progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10); var progress = parseInt(data.loaded / data.total * 100, 10);