Google Analytics
This commit is contained in:
20
javascripts/api.js
Executable file
20
javascripts/api.js
Executable file
@@ -0,0 +1,20 @@
|
||||
var getJSON = function (url, successHandler, errorHandler) {
|
||||
var xhr = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
|
||||
xhr.open('get', url, true);
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
var status;
|
||||
var data;
|
||||
|
||||
if (xhr.readyState == 4) { // `DONE`
|
||||
status = xhr.status;
|
||||
if (status == 200) {
|
||||
data = JSON.parse(xhr.responseText);
|
||||
successHandler && successHandler(data);
|
||||
} else {
|
||||
errorHandler && errorHandler(status);
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
};
|
||||
Reference in New Issue
Block a user