in src/apache-unomi-tracker.js [687:750]
ajax: function (options) {
var xhr = new XMLHttpRequest();
if ('withCredentials' in xhr) {
xhr.open(options.type, options.url, options.async);
xhr.withCredentials = true;
} else if (typeof XDomainRequest != 'undefined') {
/* global XDomainRequest */
xhr = new XDomainRequest();
xhr.open(options.type, options.url);
}
if (options.contentType) {
xhr.setRequestHeader('Content-Type', options.contentType);
}
if (options.dataType) {
xhr.setRequestHeader('Accept', options.dataType);
}
if (options.responseType) {
xhr.responseType = options.responseType;
}
var requestExecuted = false;
if (wem.timeoutInMilliseconds !== -1) {
setTimeout(function () {
if (!requestExecuted) {
console.error('[WEM] XML request timeout, url: ' + options.url);
requestExecuted = true;
if (options.error) {
options.error(xhr);
}
}
}, wem.timeoutInMilliseconds);
}
xhr.onreadystatechange = function () {
if (!requestExecuted) {
if (xhr.readyState === 4) {
if (xhr.status === 200 || xhr.status === 204 || xhr.status === 304) {
if (xhr.responseText != null) {
requestExecuted = true;
if (options.success) {
options.success(xhr);
}
}
} else {
requestExecuted = true;
if (options.error) {
options.error(xhr);
}
console.error('[WEM] XML request error: ' + xhr.statusText + ' (' + xhr.status + ')');
}
}
}
};
if (options.jsonData) {
xhr.send(JSON.stringify(options.jsonData));
} else if (options.data) {
xhr.send(options.data);
} else {
xhr.send();
}
},