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?

40% freelancers report having troubles getting paid wages they are owned Next