XHR停止所有作者请求的Ajax发布请求 [英] Ajax post request with xhr stopping all author requests
本文介绍了XHR停止所有作者请求的Ajax发布请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的要求是将文件上传到服务器. 我使用ajax电话. 当此ajax调用开始时,所有重新测试将继续进行.
my requirement is upload files to server. i using ajax call. when this ajax call starts remain all retests will goes on pending.
我的代码是:
function AddVideos(row, Video, CoverPhoto) {
var param = { "ObjectFile": Video, "CoverPhoto": CoverPhoto, "VideoID": $(row).find('span.VidoID').text() };
var Data = new FormData();
$.each(param, function (key, element) {
Data.append(key, element);
});
$.ajax({
type: 'POST',
url: '/KnowledgeAreas/AddVideos',
data: Data,
context: row,
xhr: function () {
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) {
myXhr.upload.addEventListener('progress', function (event) { progress(event, row) }, false);
}
return myXhr;
},
async: true,
cache: false,
contentType: false,
processData: false,
success: function (data) {
GetVideos();
$('#tblUploadingVideos tbody').find('span[name=' + $(row).find('span.VidoID').text() + ']').parents('tr').remove();
if ($('#tblUploadingVideos tbody tr').length == 0) {
$('#tblUploadingVideos').hide();
}
},
error: function (data) {
}
});
};
在处理此请求时.其余所有请求将在队列中停止.
while processing this request. remain all requests will stop in queue.
您可以在下面看到.
推荐答案
我已通过更新会话状态解决了此问题:
I have fixed this issue by updating session state:
[SessionState(SessionStateBehavior.ReadOnly)]
这篇关于XHR停止所有作者请求的Ajax发布请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文