 <p>You can make use of onreadystatechange event: <a href="http://www.w3schools.com/ajax/ajax_xmlhttprequest_onreadystatechange.asp" rel="nofollow">http://www.w3schools.com/ajax/ajax_xmlhttprequest_onreadystatechange.asp</a></p>