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:
parent
940b1044e9
commit
78279dc268
@ -509,6 +509,8 @@ Tomahawk.ajax = function(url, settings) {
|
|||||||
var contentType;
|
var contentType;
|
||||||
if (settings.dataType === 'json') {
|
if (settings.dataType === 'json') {
|
||||||
contentType = 'application/json';
|
contentType = 'application/json';
|
||||||
|
} else if (contentType = 'xml') {
|
||||||
|
contentType = 'text/xml';
|
||||||
} else {
|
} else {
|
||||||
contentType = xhr.getResponseHeader('Content-Type');
|
contentType = xhr.getResponseHeader('Content-Type');
|
||||||
}
|
}
|
||||||
@ -517,6 +519,11 @@ Tomahawk.ajax = function(url, settings) {
|
|||||||
return JSON.parse(responseText);
|
return JSON.parse(responseText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (~contentType.indexOf('text/xml')) {
|
||||||
|
var domParser = new DOMParser();
|
||||||
|
return domParser.parseFromString(responseText, "text/xml");
|
||||||
|
}
|
||||||
|
|
||||||
return xhr.responseText;
|
return xhr.responseText;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user