简体   繁体   English

Ajax请求在MVC项目中中止

[英]ajax request aborted in mvc project

When we try to post json data to server in MVC project. 当我们尝试将json数据发布到MVC项目中的服务器时。 firebug shows that request is aborted. firebug显示请求已中止。

I believe its fairly of some content when exec is post to iis server request aborted, when we remove exec from textarea request post and data saved fine. 我相信当exec被发布到iis服务器请求中止时,当我们从textarea请求发布中删除exec并保存数据时,它的内容相当合理。

Can anyone face similar kind of issue? 谁能面对类似的问题? We are using jquery 1.7 version. 我们正在使用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
            });
    }
} 

Request aborted in just 2 second. 请求仅在2秒钟后中止。 I tried to set timeout but it won't workout. 我尝试设置超时时间,但无法锻炼。

Is it related to iis setting? 与iis设置有关吗? can we set those settings in local environment? 我们可以在本地环境中设置那些设置吗?

Thanks in advanced! 提前致谢!

data: JSON.stringify(jsondata) 

第一次通话时失踪

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM