mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 06:36:55 +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();
|
var xmlHttpRequest = new XMLHttpRequest();
|
||||||
xmlHttpRequest.open('GET', url, true);
|
xmlHttpRequest.open('GET', url, true);
|
||||||
|
if (extraHeaders) {
|
||||||
|
for(var headerName in extraHeaders) {
|
||||||
|
xmlHttpRequest.setRequestHeader(headerName, extraHeaders[headerName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
xmlHttpRequest.onreadystatechange = function() {
|
xmlHttpRequest.onreadystatechange = function() {
|
||||||
if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
|
if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
|
||||||
callback.call(window, xmlHttpRequest);
|
callback.call(window, xmlHttpRequest);
|
||||||
|
Reference in New Issue
Block a user