Requests with JS - is this out dated?
<p>I am making a basic live chat and was wondering if i have learnt this correctly...</p>

<p>I have my call function like this:</p>

<pre><code>function call_data(url,data)
{
  if (window.XMLHttpRequest) {              
    AJAX=new XMLHttpRequest();              
  } else {                                  
    AJAX=new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (AJAX) {
  querystring = "?dta="+data;
     AJAX.open("GET", url + querystring, false);                             
     AJAX.send(null);
     return AJAX.responseText;                                         
  } else {
     return false;
  }                                             
}   

function checker(id){
        result = parseInt(call_data('check_chat.php',id)); //check new messages
        if(result){//if new message
        loadchat(id); //load the messages
        } else {
        setTimeout(function() { checker(id); }, 5000); //check for new message every 5 seconds
        }
}
</code></pre>

<p>Is this the best way to call for new messages periodically ?</p>
