【问题标题】:ajax request aborted in mvc projectajax 请求在 mvc 项目中中止
【发布时间】:2017-10-30 16:25:38
【问题描述】:

当我们尝试在 MVC 项目中将 json 数据发布到服务器时。 firebug 显示请求被中止。

我相信当 exec 发布到 iis 服务器请求中止时,当我们从 textarea 请求发布中删除 exec 并且数据保存良好时,它的一些内容。

任何人都可以面临类似的问题吗? 我们使用的是 jquery 1.7 版本。

function PostData(url, methodname, jsondata, callbackfunction) {
    if (jsondata == '') {

        $.ajax({
            type: "POST",
            //async: "true",
            contentType: "application/json",
            dataType: "json",
            url: baseUrl + url + "/" + methodname,
            success: function (html) {
                if (html != null) {
                    if (html.IsSessionExpired != null) {
                        if (html.IsSessionExpired == true) {
                            window.location.href = baseUrl + "/";
                            return;
                        }
                    }
                }

                if (typeof callbackfunction == "function") {
                    callbackfunction(html);
                }
                else {
                    eval(callbackfunction + "(" + JSON.stringify(html) + ")");
                }
            },

            error: function (request, status, error) {

            },
            timeout: 300000 // Set timeout of 3 minutes
        });
    }
    else {
            $.ajax({
                type: "POST",
                async: "false",
                contentType: "application/json",
                dataType: "json",
                url: baseUrl + url + "/" + methodname,
                data: JSON.stringify(jsondata),
                success: function (html) {
                    if (html != null) {
                        if (html.IsSessionExpired != null) {
                            if (html.IsSessionExpired == true) {
                                window.location.href = baseUrl + "/";
                                return;
                            }
                        }
                    }

                    if (typeof callbackfunction == "function") {
                        callbackfunction(html);
                    }
                    else {
                        eval(callbackfunction + "(" + JSON.stringify(html) + ")");
                    }
                },
                error: function (request, status, error) {

                },
                timeout: 300000 // Set timeout of 3 minutes
            });
    }
} 

请求仅在 2 秒内中止。我尝试设置超时,但它不会锻炼。

是否与iis设置有关?我们可以在本地环境中设置这些设置吗?

提前致谢!

【问题讨论】:

  • 你能提供你的代码吗
  • 代码已在上面的描述中添加。谢谢

标签: jquery asp.net-mvc iis iis-7.5


【解决方案1】:
data: JSON.stringify(jsondata) 

第一次通话时不见了

【讨论】:

  • if (jsondata == '') 为空所以不需要字符串化
猜你喜欢
  • 1970-01-01
  • 2018-11-09
  • 1970-01-01
  • 2014-12-01
  • 2015-12-06
  • 1970-01-01
  • 2012-12-21
  • 1970-01-01
  • 2013-09-01
相关资源
最近更新 更多