1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-13 20:39:57 +01:00

Add extra header support to Tomahawk.asyncRequest

This commit is contained in:
Leo Franchi 2012-08-27 11:52:45 -04:00
parent 74c2d0e776
commit 251200d9cd

View File

@ -184,10 +184,15 @@ Tomahawk.syncRequest = function(url)
}
};
Tomahawk.asyncRequest = function(url, callback)
Tomahawk.asyncRequest = function(url, callback, extraHeaders)
{
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open('GET', url, true);
if (extraHeaders) {
for(var headerName in extraHeaders) {
xmlHttpRequest.setRequestHeader(headerName, extraHeaders[headerName]);
}
}
xmlHttpRequest.onreadystatechange = function() {
if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
callback.call(window, xmlHttpRequest);