簡體   English   中英

Ajax請求在MVC項目中中止

[英]ajax request aborted in mvc project

當我們嘗試將json數據發布到MVC項目中的服務器時。 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設置有關嗎? 我們可以在本地環境中設置那些設置嗎?

提前致謝!

data: JSON.stringify(jsondata) 

第一次通話時失蹤

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM