0
rated 0 times
[
4]
[
4]
/ answers: 1 / hits: 19558
/ 14 Years ago, fri, february 4, 2011, 12:00:00
I have few functions, which calls another (integrated functions in browser), something like this:
function getItems () {
var xhr = new XMLHttpRequest();
xhr.open(GET, http://another.server.tld/, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
items = $(a[href^=/courses/], xhr.responseText);
}
};
xhr.send();
}
As I don't want to write more code inside and make each logical functionality separated, I need this function to return variable items.
I know there can happen some accidents (network/server is not available, has long-response...) and the function can return anything after gets data from the server or timeout occurs.
More From » callback