mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 14:46:33 +02:00
Add a Tomahawk.asyncRequest for async calls, ALL RESOLVERS SHOULD USE THIS
This commit is contained in:
@@ -184,6 +184,21 @@ Tomahawk.syncRequest = function(url)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Tomahawk.asyncRequest = function(url, callback)
|
||||||
|
{
|
||||||
|
var xmlHttpRequest = new XMLHttpRequest();
|
||||||
|
xmlHttpRequest.open('GET', url, true);
|
||||||
|
xmlHttpRequest.onreadystatechange = function() {
|
||||||
|
if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
|
||||||
|
callback.call(window, xmlHttpRequest);
|
||||||
|
} else if (xmlHttpRequest.readyState === 4) {
|
||||||
|
Tomahawk.log("Failed to do GET request: to: " + url);
|
||||||
|
Tomahawk.log("Status Code was: " + xmlHttpRequest.status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xmlHttpRequest.send(null);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Secure Hash Algorithm (SHA256)
|
* Secure Hash Algorithm (SHA256)
|
||||||
|
Reference in New Issue
Block a user