387429 (2) [Avatar] Offline
#1
I have a question on event queue, which is covered in Chapters 2 and 13: Suppose I have the following code:
var url = ...; // whatever url
var xhr = new XMLHttpRequest();
xhr.open('get', url, async);
xhr.send();

// line 6: Code that will take a long time ...

function callback() { 
  // ... 
};
xhr.addEventListener('load', callback);
xhr.addEventListener('error', callback);


If the code on line 6 will be done after the xhr request is done, will xhr's "load" and "error" events still be put into the event queue? Or these two events won't get into the queue at all because they don't have any event handlers attached to them (yet)?

Thank you very much for your help!
Inner-self (8) [Avatar] Offline
#2
Hello User#387429

Which book are you reading? My search for xhr yielded no results.

thank you.
387429 (2) [Avatar] Offline
#3
The code was not from the book. I was trying to understand how the event queue really works. Thank you for your reply.