I have a function which is saving some data by ajax and return a response.
This is my success function
success: function (response) {
if (response.d != "0") {
function clickCall(callback) {
$("#startUploadbuscase").click();
callback();
return true;
}
function redirectToAnother() {
alert('done');
}
clickCall(redirectToAnother);
}
else {
$("#divToShowOnSavingFinalBuscase").hide();
alert("Error occurred while processing Business Case");
}
},
Clickcall() should call redirecttoanother() after its execution finished as I've given callback().
The $("#startUploadbuscase").click() is starting the upload of multifile uploader as below.
$( document ).ready(function() {
function initializeUploader(type,foldername) {
$("#startUploadbuscase").unbind("click");
var uploadObj = $("#divfileuploaderbuscase").uploadFile({
url: "uploadHandler.ashx?type=" + type + "&fname=" + foldername,
method: "POST",
enctype: "multipart/form-data",
returnType: null,
allowedTypes: "jpg,png,gif,doc,docx,pdf,jpeg,rar,xls,xlsx",
fileName: "file",
formData: {},
dynamicFormData: function () {
return {};
},
maxFileSize: 5 * 1024 * 1024,
multiple: true,
dragDrop: true,
autoSubmit: false,
showCancel: true,
showAbort: true,
showDone: false,
showDelete: false,
showError: true,
showStatusAfterSuccess: true,
showStatusAfterError: true,
showFileCounter: true,
fileCounterStyle: "). ",
showProgress: true,
nestedForms: true,
showDownload: false,
onSuccess: function (files, response, xhr, pd) { },
onError: function (files, status, message, pd) { },
onCancel: function (files, pd) { },
downloadCallback: false,
deleteCallback: false,
afterUploadAll: function () {
},
uploadButtonClass: "ajax-file-upload",
dragDropStr: "<span><b>Drag & Drop Files</b></span>",
abortStr: "Abort",
cancelStr: "Cancel",
deletelStr: "Delete",
doneStr: "Done",
multiDragErrorStr: "Multiple File Drag & Drop is not allowed.",
extErrorStr: "is not allowed. Allowed extensions: ",
sizeErrorStr: "is not allowed. Allowed Max size: ",
uploadErrorStr: "Upload is not allowed",
maxFileCountErrorStr: " is not allowed. Maximum allowed files are:",
downloadStr: "Download",
statusBarWidth: 500,
dragdropWidth: 500
});
$("#startUploadbuscase").click(function () {
uploadObj.startUpload();
});
};
});
But problem is filupload doesnot stop executing the second function redirecttoanother(),I mean wheather the file upload is finished or not,the second function fired.So how to sequence it?