Response Handling
Custom response parsing with the responseParser option. Transform server responses into a consistent format.
Drag & drop files here
Server responses will appear here...
var uploader = new MultipleUpload(el, {
uploadUrl: '/api/upload',
responseParser: function(xhr) {
// Parse custom server response format
try {
var data = JSON.parse(xhr.responseText);
return {
success: data.status === 'ok',
fileId: data.id,
url: data.downloadUrl,
message: data.message || ''
};
} catch (e) {
return { success: false, message: 'Invalid server response' };
}
},
onTaskComplete: function(task) {
console.log('File ID:', task.response.fileId);
console.log('Download URL:', task.response.url);
}
});