Load profile content for selected profile
This commit is contained in:
parent
433d4c4b85
commit
93d0b7f7df
7 changed files with 109 additions and 10 deletions
30
js/Util.js
Normal file
30
js/Util.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
BR.Util = {
|
||||
|
||||
get: function(url, cb) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', url, true);
|
||||
xhr.onload = function() {
|
||||
if ((xhr.status === 200 || xhr.status === 0) && xhr.responseText) {
|
||||
cb(null, xhr.responseText);
|
||||
} else {
|
||||
cb(BR.Util.getError(xhr));
|
||||
}
|
||||
};
|
||||
xhr.onerror = function() {
|
||||
cb(BR.Util.getError(xhr));
|
||||
};
|
||||
xhr.send();
|
||||
},
|
||||
|
||||
getError: function(xhr) {
|
||||
var msg = 'no response from server';
|
||||
if (xhr.responseText) {
|
||||
msg = xhr.responseText;
|
||||
} else if (xhr.status || xhr.statusText) {
|
||||
msg = xhr.status + ': ' + xhr.statusText;
|
||||
}
|
||||
return new Error(msg);
|
||||
}
|
||||
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue