Ich benutze pure js (ohne JQuery), um eine XMLHttpRequest
Anfrage an Server zu senden.kann nicht umgehen net :: ERR_CONNECTION_REFUSED in reinem js
var _xhr = new XMLHttpRequest();
_xhr.open(type, url);
_xhr.setRequestHeader('Content-Type', 'application/json');
_xhr.responseType = 'json';
_xhr.onload = function() {
if (_xhr.status === 200) {
var _json = _xhr.response;
if (typeof _json == 'string')
_json = JSON.parse(_json);
success(_json);
} else {
error(_xhr);
}
};
_xhr.onerror = function(){
console.log('fail');
};
try {
_xhr.send(_to_send);
} catch (e){
options.error(_xhr);
}
wenn ich senden eine Anfrage, es ist nicht (das ist ok) und ich erhalte eine Fehlermeldung, aber ich CANNON Handle It. xhr.onerror
druckt Nachricht an Konsole, aber ich bekomme OPTIONS url net::ERR_CONNECTION_REFUSED
auch. Wie kann ich diese Nachricht in der Konsole vermeiden?
Auch verwende ich window.onerror
alle Fehler zu behandeln, aber ich dieses OPTIONS url net::ERR_CONNECTION_REFUSED