I upload file using jquery ajax with progressbar (xhr).
$.ajax({
url: "../Services/upload.ashx",
type: "POST",
data: formData,
cache: false,
contentType: false,
processData: false,
timeout: 60000
xhr: function () {
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) {
myXhr.upload.addEventListener('progress', that.progressHandling, false);
}
return myXhr;
}
Upload.prototype.progressHandling = function (event) {
var percent = 0;
var position = event.loaded || event.position;
var total = event.total;
if (event.lengthComputable) {
percent = Math.ceil(position / total * 100);
}
};
Progressbar works perfect. File is uploaded to the server but after upload it needs some processing server side. I try to check status of this server side processing by making another jquery ajax request.
The problem is with response from this secound call. I'm unable to receive this response because the first (file upload) is still waiting for processing.
IMHO this two request are async so why if I made file upload wiht long running server side processing is blocking me to receive any other responses from other ajax calls?
The problem is not with jquery ajax. The problem is server siade - with generic handler. It use sessions so it will block any other requests.
Please check this thread for more info:
When requests come in, Session holds an exclusive lock so that other requests from the same session will not run in parallel and must run one after the other.