Interview answers verified by specialists.

Find interview questions and answers on this website:


See right interview answers on 30 common job interview questions

How do I create a thread to do AJAX polling?

  •  JavaScript does not provide threads. JavaScript functions are called after an event occurred on a page like the page is loaded, a mouse click, or a form element get focused. 
  •  You can make a timer by using the setTimeout which requires a function name and time in milliseconds as its arguments. 
  •  Calling the same function using loop which is given in the JavaScript example below.
  function checkForMsg() {
  // start AJAX interaction with handleCallback as the callback function
  }
  // callback for the request
  function handleCallback() {
  // do post processing
  setTimeout("checkForMsg()", 20000);
  }
  Note that the checkForMessage will continue to loop infinitely. You may want to change the increment interval based on activity. You may also want to change the logic which will break the loop based on some AJAX response executing condition. 

Do you know that?

25% of freelancers saying flexibility of work schedule is the best thing about their position Next

Articles:

Getting payments for Freelancers
1. Read how to register and get earned money

2. Open account within 5 minPayoneer sing up to get free $25