【问题标题】:Ajax post request with xhr stopping all author requests使用 xhr 停止所有作者请求的 Ajax 发布请求
【发布时间】: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


    【解决方案1】:

    我已经通过更新会话状态解决了这个问题:

    [SessionState(SessionStateBehavior.ReadOnly)]
    

    【讨论】:

      猜你喜欢
      • 2018-01-08
      • 2012-09-11
      • 2016-04-18
      • 1970-01-01
      • 1970-01-01
      • 2018-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多