ajax请求在mvc项目中中止

时间:2017-05-30 09:13:31

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

当我们尝试在MVC项目中将json数据发布到服务器时。萤火虫表明请求已中止。

我认为,当 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设置有关吗?我们可以在本地环境中设置这些设置吗?

先谢谢!

1 个答案:

答案 0 :(得分:0)

data: JSON.stringify(jsondata) 
第一次通话时缺少