1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-18 23:17:59 +01:00

Add a Tomahawk.asyncRequest for async calls, ALL RESOLVERS SHOULD USE THIS

This commit is contained in:
Leo Franchi 2011-09-14 22:28:46 -04:00
parent 7f9ded7816
commit 0504bec81d

View File

@ -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)