In Microsoft Edge wird eine GET-Anforderung nicht ausgeführt. Ich habe den Code bis zur Ausführung der AJAX-Anfrage durchlaufen und einen Haltepunkt in den Callbacks festgelegt. Der Code erreicht jedoch nie die Rückrufe.Microsoft Edge-easyXDM-Ereignis ("Nachricht") wird nicht aufgerufen
Ich habe bereits eine. Then() und. Fail() Setup mit Callbacks, und versucht, eine .done() und. Always() mit Callbacks, aber keiner der Code in den Callbacks läuft.
Ich habe dann die Netzwerk-Registerkarte in Dev-Tools überprüft, und ich kann die Anfrage überhaupt nicht finden. Es scheint, als würde Edge die Anfrage aus irgendeinem Grund nicht auslösen.
request = function(options, resolveScope) {
var deferred = $.Deferred();
corsHandler.makeRequest(options)
.done(this._wrap(function(response) {
deferred.resolveWith(resolveScope, [response]); //never gets here
}, this))
.fail(this._wrap(function(response) {
deferred.rejectWith(resolveScope, [response]); //never gets here
}, this));
return deferred;
}
Dies ist, was die Anfrage Funktion oben ruft.
ajaxFunc = function(data, scope) {
return request({
url: '/path/to/server',
internalUrl: true,
method: 'GET',
datatype: 'json',
data: data
}, scope);
}
Dies ist die Implementierung, die verwendet wird, um diese Anforderung zu stellen.
(function() {
// set data var
return ajaxFunc(data, self)
.then(function(res) { console.log(res); }) //never gets here
.done(function(res) { console.log(res); }) //never gets here
.fail(function(res) { console.log(res); }) //never gets here
.finally(function(res) { console.log(res); }) //never gets here
})();
Hier ist der Cors Zeug. (Ich weiß nicht viel darüber.)
corsHandler.makeRequest = function(options) {
// resolve default options
_.defaults(options, {
xhr: null,
corsUrl: null,
url: null,
method: 'GET',
data: {},
success: function() {},
error: function() {},
terminate: false,
binary: false,
headers: {},
internalUrl: false,
datatype: ''
});
// if url is internal, create absolute url from relative url
if (options.internalUrl) {
options.url = this.createAbsoluteInternalUrl(options.url);
}
// resolve cors url or proxy url
options.corsUrl = options.corsUrl || this.getCorsUrl(options.url);
if (!options.corsUrl) {
options.url = this.getProxyUrl(options.url);
options.corsUrl = this.getCorsUrl(options.url);
}
// create xhr
if (!options.xhr && options.corsUrl) {
options.xhr = this.createXhr(options.corsUrl);
}
// create cleanup procedure
var cleanUpAfterRequest = $.proxy(function() {
if (options.terminate) {
options.xhr.destroy();
this._removeCacheXhr(options.corsUrl);
}
}, this);
// prepare deffered object
var deferred = $.Deferred();
deferred
.done(function() {
if (options.success) {
options.success.apply(null, Array.prototype.slice.call(arguments));
}
})
.fail(function() {
if (options.error) {
options.error.apply(null, Array.prototype.slice.call(arguments));
}
});
// make actual request
if (!options.xhr) {
throw 'corsHandler: xhr object was not created or defined to make request';
// this does not happen
}
options.xhr.request(
{
url: options.url,
method: options.method,
data: options.data,
binary: options.binary,
headers: options.headers,
datatype: options.datatype
},
function() {
deferred.resolve.apply(null, Array.prototype.slice.call(arguments));
cleanUpAfterRequest();
},
function() {
deferred.reject.apply(null, Array.prototype.slice.call(arguments));
cleanUpAfterRequest();
}
);
return deferred;
}
UPDATE
Es sieht aus wie das Problem in easyXDM ist. waitForReady()
feuert nicht on(window, "message", waitForReady)
im Rand. Ich schaue jetzt mehr auf das Thema.
easyXDM Snippet:
targetOrigin = getLocation(config.remote);
if (config.isHost) {
// add the event handler for listening
var waitForReady = function(event){
if (event.data == config.channel + "-ready") {
// replace the eventlistener
callerWindow = ("postMessage" in frame.contentWindow) ? frame.contentWindow : frame.contentWindow.document;
un(window, "message", waitForReady);
on(window, "message", _window_onMessage);
setTimeout(function(){
pub.up.callback(true);
}, 0);
}
};
on(window, "message", waitForReady);
// set up the iframe
apply(config.props, {
src: appendQueryParameters(config.remote, {
xdm_e: getLocation(location.href),
xdm_c: config.channel,
xdm_p: 1 // 1 = PostMessage
}),
name: IFRAME_PREFIX + config.channel + "_provider"
});
frame = createFrame(config);
}
Die obige Snippet läuft, aber die waitForReady
Methode nie aufgerufen. Der einzige Browser, in dem es nicht aufgerufen wird, ist Edge (funktioniert in IE8 +, Chrome, Safari, FF und mobilem Chrome/Safari).
Ist das Attribut nicht dataType nicht Datentyp? Denke nicht, dass das das Problem wäre, aber es lohnt sich zu korrigieren. Ich habe Anfragen erlebt, die in der Vergangenheit fehlgeschlagen sind, als ich diesen Fehler gemacht habe. –
würde nicht schaden, 'console.log' zu setzen, einfach überall, wo' 'done'' .fail' 'dann' ist, um zu sehen, was läuft. – SoluableNonagon
@AntonioManente Danke für die Eingabe, ich werde das untersuchen. – Jacques