mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Add extra header support to Tomahawk.asyncRequest
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user