1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-17 22:38:33 +01:00

[tomahawk.js] Add support for xml responses in Tomahawk.ajax

This commit is contained in:
Dominik Schmidt 2015-01-13 00:03:35 +01:00
parent 940b1044e9
commit 78279dc268

View File

@ -509,6 +509,8 @@ Tomahawk.ajax = function(url, settings) {
var contentType;
if (settings.dataType === 'json') {
contentType = 'application/json';
} else if (contentType = 'xml') {
contentType = 'text/xml';
} else {
contentType = xhr.getResponseHeader('Content-Type');
}
@ -517,6 +519,11 @@ Tomahawk.ajax = function(url, settings) {
return JSON.parse(responseText);
}
if (~contentType.indexOf('text/xml')) {
var domParser = new DOMParser();
return domParser.parseFromString(responseText, "text/xml");
}
return xhr.responseText;
});
};