function getJSON(url, placeholderForCallback){
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.onprogress = function(event){
console.log(event.loaded, event.total);
};
request.addEventListener('load', function(){
if(request.status < 400){
placeholderForCallback(request);
}
});
request.send(null);
}
getJSON('http://api.open-notify.org/astros.json', function(placeholder){
console.log(placeholder.responseText);
});
I've got three Questions:
1. Which event is passed to the function request.onprogress()
?
2. Why can't I see request.onprogres()
invocation? Instead, there is a property with the value null
before initialization:
printscreen of console
3. Is this event passed to the function every period of time or event fire? In case of event fire - why can't I see request.addEventListener('event', request.onprogres())
anywhere?