DOMException: Failed to execute 'send' on

2019-02-16 05:02发布

I'm trying to retrieve an XML from a cross-domain server via the ajax jQuery's method and the following error message appears on the console:

DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load: 'http://foreign.domain/...'

The code that brings this error is:

var temp = $.ajax({
    url : url,
    async : false
    dataType : "xml",
    success : function(xml) {
        // irrelevant for the case
    },
    error : function(xhr, textStatus, error) {
        console.warn('An error occured while loading the following URL: "%s". Error message: %s', url, error);
    }
});

1条回答
何必那么认真
2楼-- · 2019-02-16 05:43

The problem is the synchronous option specified by:

async: false,

This seems not to work in Chrome probably because of the specification of the jQuery's ajax method, which says:

Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation.

The strange of the situation is that Firefox and Internet Explorer seem to ignore that specification and they both perform the http request and return the XML result.

查看更多
登录 后发表回答