Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

jquery - DOMException: Failed to execute 'send' on 'XMLHttpRequest' on Chrome only

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);
    }
});
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...