The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

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.