2

我对我的服务器进行 ajax 调用以获取数据:

function LoadWebViewFile() {
    var currentURL = null;
    $.ajax({
        url: 'Default.aspx/LoadWebViewFile',
        type: 'POST',
        contentType: 'application/json; charset=utf-8',
        async: false,
        dataType: "json",
        data: '{ "FileID": "' + Documents.getSelectedID() + '" }',
        success: function(Result) {
            var ClientResponse = JSON.parse(Result.d);
            if (ClientResponse.Success) {
                currentURL = ClientResponse.Data;

            }

            else {
                showPopUpDialog('indicator', {
                    message: ClientResponse.Message,
                    type: 'error'
                }, false);
            }
        },
        error: function(xhr, textStatus, errorThrown) {
            alert(xhr.responseText);
            alert("An AJAX error occured: " + textStatus + "\nError: " + errorThrown);

            showPopUpDialog('indicator', {
                    message: 'An error occured while trying to load the file',
                    type: 'error'
                }, false);
        }
    });

    return currentURL;
}

它在 PC 上运行良好(即 chrome),但在 Safari 和 chrome 上使用 IPAD 时会失败,并且数据很大(意味着在服务器端需要更多时间)。

我得到的错误是:

NETWORK_ERR:XMLHttpRequest 异常 101

而且我不知道为什么...我无法将 async 更改为 false 因为没有任何效果。

4

1 回答 1

3

IOS webengine 将 ajax 请求的 10 秒超时报告为错误 101。因此我很头疼。

如果你同步调用你的数据,你似乎不走运。要么让服务器在 10 秒内响应,要么更改为异步并添加超时。

另请参阅http://propercode.com/?p=32

于 2013-11-06T12:28:33.957 回答