【发布时间】:2018-02-03 07:38:07
【问题描述】:
我的要求是将文件上传到服务器。 我使用ajax调用。 当此 ajax 调用开始时,所有重新测试都将继续进行。
我的代码是:
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) {
}
});
};
在处理这个请求时。仍然所有请求都将停止在队列中。
你可以在下面看到。
【问题讨论】:
标签: javascript jquery .net ajax amazon-s3